Open Question: Help Me out in this java program pls?
I only been learning java for a couple of months so i’m not so good in it. Can you help me in my Program? I have to check whether the telephone number entered(maltese number) is correct. The telephone number must be entered beginning with 21;27;79;99;23;77 and must be followed by 6 numbers….thanks
My program is:
import java.util.*;
public class MatchTelephone{
public static void main (String args[]){
Scanner kb = new Scanner(System.in);
System.out.print(“Enter Telephone Number: “);
String num = kb.next();
if (num.matches (” {21;27;79;99;23;77} [0-9]+{6}” ))
System.out.print (” The number is valid “);
else
System.out.print (“The number is invalid “);
}
}
Tags: Import Java, Java Class, Java Program, Learning Java, Main String, Number String, Open Question, Scanner System, String Args, Telephone Number
Posted in Technology
No Comments