I need some help!! I need to have a user input a phone number and then spit it out using StringTokenizer. This is what I have so far:
import java.util.*;
import java.io.*;
class Prob8_2
{
public static void main (String []args)throws IOException
{
BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
String phonen = null;
String token = null;
do
{
//user enters phone number
System.out.print( "Enter phone number: " );
System.out.flush();
phonen = stdin.readLine();
//some error checking
if ( phonen == null || phonen.length() != 12)
{
System.out.println( "Please enter phone number in this format \"555-555-5555\"." );
System.out.flush();
}
}
/ This is where I'm lost....It has to be printed out in the similar to the
// following:
// 555 is the area code
// 555 is the exchange
// 5555 is the extension
while (phonen == null || phonen.length() != 12 );
{
tokenizer = new StringTokenizer(phonen, "-");
}
System.out.print(getAreaCode(tokenizer) + " is the area code");
System.out.print(getExchange(tokenizer) + " is the exchange");
System.out.print(getExtension(tokenizer) + " is the extension");