import java.io.*;
import java.util.Hashtable;

/**
 * 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 Hashtable
 * class.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 2.0 (Using type-safe generics)
 */
public class CallerID
{

    /**
     * The entry point of the program
     *
     * @param args  The command-line arguments
     */
    public static void main(String[] args)
    {
	BufferedReader                in;
	Hashtable<String, String>      names;       // v2.0
	String                        id, number;

	in = new BufferedReader(new InputStreamReader(System.in));

	// Construct a new Hashtable
	names = new Hashtable<String, String>();   // v2.0


	// Fill the Hashtable
	names.put("540-568-8746","Abzug, C.");
	names.put("540-568-1667","Adams, E.");
	names.put("540-568-1671","Bernstein, D.");
	names.put("540-568-2779","Cushman, P.");
	names.put("540-568-2745","Eltoweissy, M.");
	names.put("540-568-2529","Eskandarian, A.");
	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-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.");
	names.put("540-568-6305","Redwine, S.");
	names.put("540-568-2770","Reynolds, C.");
	names.put("540-568-8764","Tucker, R.");


	// Prompt the user to enter a phone number
	// and then display the appropriate name
	do {

	    number = "";
	    System.out.print("Phone Number: ");

	    try {
		number = in.readLine();

		id = names.get(number);          // v2.0

		if (id != null) System.out.println(id);

	    } catch (IOException ioe) {

		ioe.printStackTrace();
	    }
	    
	} while (!number.equals(""));


    }

}
