Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Q2
- {
- public static void main(String[] args){
- Scanner kb=new Scanner(System.in);
- while (true){
- System.out.print("Enter your phone number: ");
- String number=kb.next();
- if(number.equals("exit")){
- System.exit(0);
- }
- boolean valid=true;
- for(int i=0;i<number.length();i++){
- if(number.length()!=10) valid=false;
- }
- if (valid) System.out.println("It is valid");
- else System.out.println("It is invalid");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement