Tag Archives: Regex

Java check phone number

Program asks for a phone number and checks if it is valid. CheckPhoneNo.java: import java.util.Scanner; public class CheckPhoneNo { boolean go=true; private void run() { Scanner reader=new Scanner(System.in); String phoneNo; while(go) { System.out.println(“Enter a phone number (6-15 numbers, may include an area code and spaces)”); phoneNo = reader.nextLine(); String phoneNoWithoutSpaces=removeSpaces(phoneNo); checkPhoneNo(phoneNoWithoutSpaces); } reader.close(); } privateā€¦ Read More »