1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
taurus [48]
3 years ago
8

In java write a program: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). That list is followed by a name, and your program should output that name's phone number. 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 Frankthe output is:867-5309Your 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[] nameVec, String[] phoneNumberVec, String contactName, int arraySize)Hint: Use two arrays: One for the string names, and the other for the string phone numbers.
Computers and Technology
1 answer:
BigorU [14]3 years ago
4 0

Answer:

import java.util.Scanner;

public class ContactInformation

{

public static String GetPhoneNumber(String[] nameVec, String[] phoneNumberVec, String contactName, int arraySize)  

{  

for(int i=0;i<arraySize;i++)

{

if(nameVec[i].equals(contactName))  

return phoneNumberVec[i];

}  

return "Contact doesn't exists!";

}

public static void main(String[] args)

{

int records;

Scanner sc = new Scanner(System.in);

System.out.print("Enter the size of contact List :");

records=sc.nextInt();

String[] contactNameList=new String[records];

String[] phoneNumberList=new String[records];

String contactName;

System.out.println("Enter the contact name and phone number :");

for(int i=0;i<contactNameList.length;i++)

{  

contactNameList[i]=sc.next();  

phoneNumberList[i]=sc.next();  

}  

System.out.println("Enter the name of the contact to be searched :");  

contactName=sc.next();

System.out.println(GetPhoneNumber(contactNameList,phoneNumberList,contactName,records));  

}  

}

Explanation:

In the following the function defined above for getting the contact

number on the basis of contact number provided we are checking the contact name list if we are able to find the contact name and if we did we return the contact number on the same index from the contact number list

which we found in the contact name list.

You might be interested in
Given the arra
Scrat [10]

Answer: B. hummer

Explanation:

Given the array :

Given the arra

("explorer", "testa", "hummer", "corvette", "civic", "mustang")

Array indexing usually begins from 0

That is ; the first element in the array is indexed as being in position 0

Using the given array as an example :

Index ____ element

0 ______ explorer

1 _______ tester

2 _______hummer

3 _______ corvette

4 _______ civic

5 _______ mustang

Hence, element in index 2 of the array is hummer

4 0
3 years ago
Use the drop-down menus to complete statements about the Quick Steps function.
Sloan [31]

Answer:

  1. pray the god for your answer

Explanation:

I lllllllllllllll believe the Jesus

7 0
2 years ago
Need help plz 100 POINTS
steposvetlana [31]

Answer:

salamat sa points wreker

7 0
2 years ago
Read 2 more answers
Viktor has climbed a tall tree to get a good view of the giraffes on the savannah. He is snapping lots of photographs of the gir
igomit [66]

Answer: C. a good vantage point

3 0
3 years ago
The domain in an email message tells you the
bezimeni [28]
The question is asking to choose among the following choices that state what would the domain in an email represents, base on my research, I would say that the answer would be letter B. location of the destination. I hope you are satisfied with my answer and feel free to ask for more 
8 0
3 years ago
Other questions:
  • Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
    5·1 answer
  • The term "Cloud" refers to what option(s) below? (Select all that apply)
    13·1 answer
  • Write the definition of a function printDottedLine, which has no parameters and doesn't return anything. The function prints to
    10·1 answer
  • What are the five types of alignment in Word?
    12·2 answers
  • What is an identified component of a software program that might allow a hacker or other intruder to gain entry and control of a
    10·2 answers
  • Select the correct answer.
    10·2 answers
  • When you use an external style sheet with an HTML document, you get all but one of the benefits that follows. Which one is NOT a
    15·1 answer
  • Anyone have an answer for 4.9 lesson code practice
    9·1 answer
  • What is the BCC feature used for?
    12·2 answers
  • Discuss the ways you can perform to prevent your computer/device and its data/contents from being stolen. Define two-facto authe
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!