Question: Program in java You will write a phone book program consisting of two classes: PhoneNumbe This class represents a phone number as three separate String
You will write a phone book program consisting of two classes: PhoneNumbe This class represents a phone number as three separate String objects: area code, prefix and number. For example, if the phone number is 610-499-4035, then the area code is "610, the prefix is "499" and the number is "4035". public class PhoneNumber l private String areaCode; I/ first 3 digits private String prefix 7/ next 3 digits private String number last 4 digits The constructor has exactly one parameter, which is the phone number represented asa single string with the format "610-499-4035". The constructor must divide the single string into three separate strings in order to initialize the three fields. GoogleTM Java String" to find information on the methods available in the String class. This class also must include a toString method that returns the phone number as a single String of the form "(610) 499-4035" PhoneBook: This class represents a phone book, associating people's names with their phone numbers. Use a HashMap with names as keys and PhoneNumber objects as values. public class PhoneBook private HashMap
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
