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
The command to get out of the loop.<br>a.<br>i exit<br>ii. break<br>iii. comment<br>iv. for​
Pavel [41]

Answer:

ii. break

Explanation:

In Computer programming, a loop can be defined as a sequence of instructions that are executed repeatedly until a specific condition is true or for a certain number of times.

This ultimately implies that, a loop is a programming structure that continually repeats a sequence of instructions until a specific condition is true (met) or for a definite number of times.

Basically, there are three (3) main types of loop in programming and these includes;

I. For loop.

II. While loop.

III. Repeat.

Since loops continually repeats a sequence of instructions until a specific condition is true (met), it is a best practice to ensure that the loop breaks at some point to avoid an infinite loop. An infinite loop typically causes a software program to crash.

Thus, the break command is used by programmers to prevent an infinite loop or terminate a current loop immediately.

Hence, the command to get out of the loop is break.

7 0
3 years ago
Keeping memos on your checks is important because they
Anastasy [175]

Answer: they can determine how you get paid, so if you get a memo about schedules, and you work hourly, you keep keep that memo to show that you are following direction in hours, which result in getting paid more/less.

8 0
3 years ago
NO LINKS&lt;br /&gt;Write a C program called velocity.c to do the following activities.&lt;br /&gt;• The parent process should r
algol [13]

Answer:

uhm.....im confused a bit here

3 0
3 years ago
Aubrey uses the following formula to calculate a required value. Which elements of the formula use mixed cell referencing?
iris [78.8K]

Answer:

$1A

brainiest plz

Explanation:

The elements of a formula only can have the following format:

1) Letter Number as C1

2) Letter $ Number as A$1

3) $ Letter Number as $A1

4) $ Letter $ Number as $A$1

The element $1A is not in the format

5 0
3 years ago
Read 2 more answers
Which option is a temporary storage area in memory that is created to hold data?
Gemiola [76]
A subprocedure explanation: because it is
5 0
2 years ago
Read 2 more answers
Other questions:
  • The bias condition for a transistor to be used as a linear amplifier is called:________.
    14·1 answer
  • You have just made changes to a GPO that you want to take effect as soon as possible on several user and computer accounts in th
    7·1 answer
  • In case of an emergency, once you or someone already on the scene has contacted 9-1-1, the next thing to do is: A) Move them to
    9·2 answers
  • In which country did the World Cyber Games originate?
    9·2 answers
  • Question 19
    9·2 answers
  • What was the first edition of the internet?
    7·1 answer
  • What should I change my fortnite name to:<br> Barneys broken thumb or I dont have aim assist
    6·1 answer
  • If Jake wants to find out if the size of a fruit has any effect on the total sales for the week of that particular fruit, what c
    15·1 answer
  • What physical disk oriented performance counter should be used to determine the number of requests waiting to be processed by a
    9·1 answer
  • Which of the following statements is false? A. The internet has developed at a consistent rate throughout the world. B. There ar
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!