public class ifExamples
{
    public static void main (String args[])
    {
	new ifExamples ();
    }


    public ifExamples ()
    {
	//An if with STRINGS
	//Asks a riddle and tells them if they are correct
	String answer = IO.inputString ("What falls in the winter, but does get hurt? ");
	if (answer.equals ("snow") || answer.equals ("Snow"))
	    System.out.println ("That is correct!");
	else if (answer.equalsIgnoreCase ("snowflake"))
	    System.out.println ("You got it!");
	else if (answer.equalsIgnoreCase ("ice"))
	{
	    System.out.println ("That was pretty close.");
	    System.out.println ("The answer was \"snow\".");
	}
	else
	{
	    System.out.println ("Sadly, that is incorrect.");
	    System.out.println ("The answer was \"snow\".");
	}

	//An if with CHARS
	//Adds 5+5 if the users wants them added
	System.out.println ("");
	char first = IO.inputChar ("Should I add 5+5? (y/n) ");
	if (first == 'y' || first == 'Y')
	{
	    System.out.println ("No problem.");
	    System.out.println ("5+5 = 10");
	}
	else
	    System.out.println ("OK. I won't.");

	//An if with INTS
	//Asks a random addition question
	System.out.println ("");
	int num1 = (int) (Math.random () * 5);
	int num2 = (int) (Math.random () * 5);
	int ans = IO.inputInt ("What is " + num1 + " + " + num2 + "? ");
	int correct = 0;
	if ((num1 + num2) == ans)
	{
	    System.out.println ("You got it!");
	    correct++;
	}
	else
	{
	    System.out.println ("That was incorrect.");
	    System.out.println ("It was " + (num1 + num2) + ".");
	}
	//second question
	num1 = (int) (Math.random () * 5);
	num2 = (int) (Math.random () * 5);
	ans = IO.inputInt ("What is " + num1 + " + " + num2 + "? ");
	if ((num1 + num2) == ans)
	{
	    System.out.println ("You got it!");
	    correct++;
	}
	else
	{
	    System.out.println ("That was incorrect.");
	    System.out.println ("It was " + (num1 + num2) + ".");
	}
	//score out of 2
	System.out.println ("You got a total of " + correct + " right out of 2");

    }
}
