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
Write a loop that reads strings from standard input where the string is either "land", "air", or "water". The loop terminates wh
____ [38]

Answer:

count_land = count_air = count_water = 0

while True:

   s = input("Enter a string: ")

   if s == "xxxxx":

       break

   else:

       if s == "land":

           count_land += 1

       elif s == "air":

           count_air += 1

       elif s == "water":

           count_water += 1

print("land: " + str(count_land))

print("air: " + str(count_air))

print("water: " + str(count_water))

Explanation:

*The code is in Python

Initialize the variables

Create a while loop that iterates until a specific condition is met. Inside the loop, ask the user to enter the string. If it is "xxxxx", stop the loop. Otherwise, check if it is "land", "air", or "water". If it is one of the given strings, increment its counter by 1

When the loop is done, print the number of strings entered in the required format

4 0
2 years ago
New evidence can lead to a change in scientific knowledge.<br><br> A. True<br> B.False
lidiya [134]

ιт ιѕ (α.) тяυє ιf уσυ fιи∂ иєω киσωℓєgє σи ∂σмєтнιиg ιт ¢αи ¢нαиgє ѕ¢ιєи¢є

ℓιкє нσω тнєу υѕє∂ тσ вєℓινє тнє єαятн ωαѕ fℓαт,σя нσω тнє єαятн ωαѕ тнє ¢єитєя σf тнє υиινєяѕє

нσρє ι ¢συℓ∂ нєℓρ уσυ!!!!!!!!

3 0
3 years ago
Read 2 more answers
What happens once the Insert tab is used in PowerPoint to insert a chart into a presentation?
nordsb [41]

Answer:

•The user can edit the chart directly. hoped i;m right

Explanation:

6 0
2 years ago
ASAP!!!!!!! 6.From Excel to PowerPoint, you can copy and paste
KIM [24]
Your answer is A.

<em>Let me know if you have any other questions! ♥</em>
4 0
3 years ago
2.3.<br> Why is a foundation of particular importance when building and designing<br> structures?
bearhunter [10]

Answer:

A foundation plays three major roles in the construction of a structure. A good and strong foundation keeps the building standing while the forces of nature wreak havoc. Well-built foundations keep the occupants of the building safe during calamities such as earthquake, floods, strong winds etc.

6 0
2 years ago
Other questions:
  • Think about a time when someone made a biased judgment about you or acted unfairly toward you because of your age, skin color, c
    6·1 answer
  • Which organizational pattern would probably be most effective for arranging the main points of a speech with the specific purpos
    15·1 answer
  • Prove that for every nfa with an arbitrary number of final states there is an equivalent nfa with only one final state. Can we m
    8·1 answer
  • In one sentences describe how to change your home page
    10·1 answer
  • Multiple users report that the network printer, which is connected through the print server, is not printing. Which of the follo
    12·1 answer
  • Universal Containers has a sales team focused on renewals. They will use many of the same Opportunity fields as other teams, but
    13·1 answer
  • Which of the following are documents that can help you to review and assess your organization’s status and state of security? Fi
    6·1 answer
  • Each of the outcomes listed below is a result of executing the following script except for one. Which one? CREATE ROLE ExampleRo
    6·1 answer
  • Identify the characteristics of logic problems. Select all that apply.
    11·2 answers
  • MSWord is a popular___________ program.​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!