Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Q2
  3. {
  4. public static void main(String[] args){
  5. Scanner kb=new Scanner(System.in);
  6. while (true){
  7. System.out.print("Enter your phone number: ");
  8. String number=kb.next();
  9. if(number.equals("exit")){
  10. System.exit(0);
  11. }
  12. boolean valid=true;
  13. for(int i=0;i<number.length();i++){
  14. if(number.length()!=10) valid=false;
  15. }
  16. if (valid) System.out.println("It is valid");
  17. else System.out.println("It is invalid");
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement