// GuessingGame.java
// by Bryson Payne
import javax.swing.*;

public class GuessingGame
{
	public static void main(String[] args)
	{
		int response;
		do
		{
			int guess;
			int theNumber =  (int) ( Math.random()*100 );
			String guessType = "";
			do
			{
			
				String theGuess = JOptionPane.showInputDialog(null,
						guessType + " Guess a number between 1 and 100");
				if (theGuess == null)
					System.exit(1);
				guess = Integer.parseInt(theGuess);
				if (guess == theNumber)
					JOptionPane.showMessageDialog(null,
						"You Won! The number was " + theNumber);
				else if (guess > theNumber)
					JOptionPane.showMessageDialog(null,
						"Too high...");
				else 
					JOptionPane.showMessageDialog(null,
						"Too low...");
			} while (guess != theNumber);
			response = JOptionPane.showConfirmDialog(null,
							"Wanna Play Again (y/n)?",
							"Guessing Game",
							JOptionPane.YES_NO_OPTION);
		}while(response == 0 );
		System.exit(0);
	}
}