/*
 * Code7.java
 * Dan Armendariz
 * Computer Science S-76
 *
 * A better version of reading values from the keyboard, with exception
 * handling.
 *
 */

// allow us use of the keyboard scanner. More information from the docs:
// http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
import java.util.Scanner;

class Code7 {

	public static void main(String [] args) {

		int number = 123;
		int input = 0;

		// instantiate the Scanner class, accessing data from the keyboard
		Scanner keyboard = new Scanner(System.in);

		System.out.print("Please enter an integer: ");		

		// try inputting an integer, if a user doesn't ..
		try {

			input = keyboard.nextInt();

		} catch(Exception e) {
			// an exception will be thrown, and we can catch it to alert
			// the user that something bad happened.

			System.out.println("Invalid input! Quitting..");
			System.exit(1);
		}

		// test to see if what the user entered matches our number.
		if(input == number) {
			System.out.println("Numbers match! :-)");
		} else {
			System.out.println("Numbers do not match! :-(");
		}

	}

}