Respuesta :
Answer:
/ Contactlist.java
import java.util.Scanner;
public class PhoneContacts
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 "";
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String[] names = new String[n];
String[] numbers = new String[n];
for (int i = 0; i < n; i++) {
names[i] = in.next();
numbers[i] = in.next();
}
System.out.println(GetPhoneNumber(names, numbers, in.next(), n));
}
}
In this exercise we have to use the knowledge of computational language in JAVA to describe the code, like this:
We can find the code in the attached image.
The code can be written more simply as:
/ Contactlist.java
import java.util.Scanner;
public class PhoneContacts
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 "";
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String[] names = new String[n];
String[] numbers = new String[n];
for (int i = 0; i < n; i++) {
names[i] = in.next();
numbers[i] = in.next();
}
System.out.println(GetPhoneNumber(names, numbers, in.next(), n));
}
}
See more about JAVA at brainly.com/question/2266606
