Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6.40 LAB: Contact list A contact list is a place where you can store a specific contact with other associated information such as a

student submitted image, transcription available belowstudent submitted image, transcription available below  

6.40 LAB: Contact list 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. Ex: If the input is: 3 Joe, 123-5432 Linda, 983-4123 Frank, 867-5309 Frank the output is: 867-5309 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 getPhone Number (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. 480462.3568798.qx3zqy7 import java.util.Scanner; public class LabProgram { /* Define your method here */ public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int size scnr.nextInt(); string[] name = new String[size]; String[] number = new String[size]; String[] str = new String[size]; String temp char c; = ; int i; int j; for (i=0; i < size; ++i) { str[i] scnr.next(); for (j=0; j < str[i].length(); ++j) { C = str[i].charAt(j); if (Character.isLetter(c) temp += c; == true) { } } } name[i] = temp; System.out.println(name[i]); for (i=0; i < size; ++i) { str[i] scnr.next(); for (j = 0; j < str[i].length(); ++j) { C = str[i].charAt(j); if (Character.isDigit(c) == true || c == '') { temp += c; } } number[i] = temp;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management Leading And Collaborating In The Competitive World

Authors: Thomas Bateman, Scott Snell

9th Edition

0078137241, 9780078137242

More Books

Students also viewed these Programming questions