import java.util.HashMap;
import java.util.Scanner;

/**
 * A simple class for performing a "Caller ID" (i.e., look up a
 * person's name given their phone number)
 *
 * This class illustrates the use of the HashMap class.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class CallerID
{

    /**
     * The entry point of the program
     *
     * @param args  The command-line arguments
     */
    public static void main(String[] args)
    {
	HashMap        names;
        Scanner        scanner;        
	String         id, number;



        scanner = new Scanner(System.in);
        
	// Construct a new HashMap
	names = new HashMap();


	// Fill the Hashtable
	names.put("540-568-1671","Bernstein, D.");
	names.put("540-568-2773","Fox, C.");
	names.put("540-568-6288","Grove, R.");
	names.put("540-568-2774","Harris, A.");
	names.put("540-568-8771","Harris, N.");
	names.put("540-568-8745","Heydari, H.");
	names.put("540-568-2772","Lane, M.");
	names.put("540-568-2727","Marchal, J.");
	names.put("540-568-2775","Mata-Toledo, R.");
	names.put("540-568-2777","Norton, M.");


	// Prompt the user to enter a phone number
	// and then display the appropriate name
	do 
        {
	    System.out.printf("Phone Number: ");
	    number = scanner.nextLine();

	    id = (String)(names.get(number));

	    if (id != null) System.out.printf("%s\n", id);
	} 
        while (!number.equals(""));
    }

}
