Posted on

A contact list is a place where you can store a specific contact with other associated information

A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings), separated by a comma. That list is followed by a name, and your program should output the phone number associated with that name. Output "None" if name is not found. Assume that the list will always contain less than 20 word pairs. Hint: here we are going to use oversize array again, so we need a variable to track the number of values in the array. You can use 20 as array capacity. Be careful: Word pairs consist of a name and a phone number (both strings) String[]contactNames=newString[20]; String[]contactNumbers=newString[20]; Important Note: Your output needs to match the required output including the space see Ex: Ex: If the input is: 3 Joe, 123-5432 Linda, 983-4123 Frank,867-5309 Frank the output is: 8675309 Your program must define and call the following method. The return value of getPhoneNumber is the phone number associated with the specific contact name. public static String getPhoneNumber(String[] nameArr, String[] phoneNumberArr, String contactName, int arraySize) Hint: Use two arrays: One for the string names, and the other for the string phone numbers. Please note that the input has comma. You would need to deal with the comma using indexOf and substring. int comma = userInput.indexOf(","); contactNames[i] = userlnput.substring(0, comma); contactNumbers[i] = userInput.substring(comma + 1); 487182.3555262.qx3zqy7 LAB 20.3.1: LAB 3.3: Contact list 3/10 ACTIVITY LabProgram.java Load default template... import java.util.Scanner; public class LabProgram { /* Define your method here */ public static void main(String[ ] args) { /* Type your code here. */ } }

A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc.

Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings), separated by a comma. That list is followed by a name, and your program should output the phone number associated with that name. Output “None” if name is not found.

Assume that the list will always contain less than 20 word pairs.

Hint: here we are going to use oversize array again, so we need a variable to track the number of values in the array. You can use 20 as array capacity. Be careful: Word pairs consist of a name and a phone number (both strings)

String[]contactNames=newString[20];
String[]contactNumbers=newString[20];

Important Note: Your output needs to match the required output including the space see Ex:

Ex: If the input is:
3
Joe, 123-5432
Linda, 983-4123
Frank,867-5309

Frank

the output is:
8675309

Your program must define and call the following method. The return value of getPhoneNumber is the phone number associated with the specific contact name.

public static String getPhoneNumber(String[] nameArr, String[] phoneNumberArr, String contactName, int arraySize)

Hint: Use two arrays: One for the string names, and the other for the string phone numbers. Please note that the input has comma. You would need to deal with the comma using indexOf and substring.

int comma = userInput.indexOf(“,”);
contactNames[i] = userlnput.substring(0, comma);
contactNumbers[i] = userInput.substring(comma + 1);

487182.3555262.qx3zqy7
LAB 20.3.1: LAB 3.3: Contact list
3/10
ACTIVITY
LabProgram.java
Load default template…

import java.util.Scanner;

public class LabProgram {
/* Define your method here */

public static void main(String[ ] args) {
/* Type your code here. */
}
}


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (5 ratings) 5 out of 5 people found this solution helpful.