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
Give 3 reasons why it is believed that smart phones precent us from communicating face to face.give three reasons why it is beli
gregori [183]

Answer:

yes

Explanation:

because the people will be lazy to go and talk to that person instead They will call each other and discuss

7 0
1 year ago
Initially, later, and finally are examples of what kind of words
Klio2033 [76]
Im pretty sure that the correct answer is Transition words.
3 0
3 years ago
What provision of the Government Paperwork Elimination Act was designed to encourage a paperless society?
Ratling [72]
<span>Validation of electronic signatures was designed to encourage a paperless society.</span>
8 0
3 years ago
Read 2 more answers
Why is it important to identify cables and conductors?​
nlexa [21]

Answer:

While we almost never get to see most of the cables, they power everything so it only makes sense that you should know what the different types of cables and wires are, so that you can pick accordingly and have your equipment, devices and appliances powered properly.

It is also important to identify cables and conductors for safety purposes, such as emergencies linked with electricity.

8 0
2 years ago
Terrence smiles at his customers, helps his coworkers, and stays late when needed. What personal skill does Terrence demonstrate
Salsk061 [2.6K]
Friendliness or it shows that he follows the rules
6 0
3 years ago
Read 2 more answers
Other questions:
  • The purchase and subsequent sale of a securities position in a customer account solely to generate commissions is____________.
    15·1 answer
  • An airline company would like to easily locate lost luggage. What technology would make it easier for them to locate the luggage
    6·2 answers
  • A model release can be either oral or written down. true or false
    11·2 answers
  • A tower or mini tower pc is a type of all- in -one unit true or false
    9·2 answers
  • To rename a database object, press and hold or right-click the object in the navigation pane and then tap or click ____ on the s
    10·1 answer
  • Which of these is not the correct method for moving text in a document in Word 2016?
    14·2 answers
  • Fill in this function that takes three parameters, two Strings and an int. 4- // Write some test function calls here! The String
    9·1 answer
  • F
    9·1 answer
  • If you want to change the name of a folder that stores Word documents, what should you do before changing the
    15·1 answer
  • you have been using snmp on your network for monitoring and management. you are concerned about the security of this configurati
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!