the following is what I have so far.
import java.util.Scanner;
import java.lang.*;
public class NameDirectory {
static String [] names = { "Harrison, Rose" , "James, Jean" , "Smith, William" , "Smith, Brad" };
static String [] phones = { "5552234" , "5559098" , "5551234" , "5556542" };
public static void main(String[] args) {
String lookup; //to hold a lookup string
//create a Scanner object for keyboard input
Scanner keyboard = new Scanner(System.in);
//Get a partial name to search for
System.out.println ("\nEnter the first few characters of the last name to lookup: \n ");
lookup = keyboard.nextLine();
for ( String person : names)
if (person.startsWith(lookup))
System.out.println(person);
else
System.out.println ("Does not Match");
}
}
I need to be able to search the name array by entering the first three letters of the name and then
it should present the name + phone. Got the first part just dont know how to get the phone number to pop up. Any help would be appreciated I can usually do this but for some reason I cant figure it out.

New Topic/Question
Reply
MultiQuote











|