hi i have this HW assignment and i cant figure it out.... If anyone can help me out i would apprciate it thanks...
A class that uses the StringTokenizer class to identify
the parts of a phone number. Assume that the format of the phone
number is (nnn) nnn-nnnn. Example (860) 222-3344. The class should
have at least three public methods: one returning the area code,
one returning the exchange and one returning the extension.
This is what i came up with....
import java.util.StringTokenizer;
class First_Rest {
public static void main (String[] args) {
String number = "(203) 919 - 0136";
StringTokenizer st = new Stringtokenizer (number, "()");
System.out.println ("Number of tokens = " + st.countTokens ());
System.out.println ("Area Code = " = st.nextToken ());
System.out.println ("Exchange = " = st.nextToken (") -"));
System.out.println ("Extension = " = st.nextToken ());
}
}
A class that uses the StringTokenizer class to identify
the parts of a phone number. Assume that the format of the phone
number is (nnn) nnn-nnnn. Example (860) 222-3344. The class should
have at least three public methods: one returning the area code,
one returning the exchange and one returning the extension.
This is what i came up with....
import java.util.StringTokenizer;
class First_Rest {
public static void main (String[] args) {
String number = "(203) 919 - 0136";
StringTokenizer st = new Stringtokenizer (number, "()");
System.out.println ("Number of tokens = " + st.countTokens ());
System.out.println ("Area Code = " = st.nextToken ());
System.out.println ("Exchange = " = st.nextToken (") -"));
System.out.println ("Extension = " = st.nextToken ());
}
}