//File:	SuffixLoop2.java
/*
After trying to test all of the possibilities, we decided
that it would be nice if the computer could just ask us if
we wanted to continue.  Then, we wouldn't have to keep
running our program again to try different numbers.

This brings us to the third of the big three ideas in
structured programming, repetition or loops.

All we need do is wrap up what we had done before into
a loop that keeps repeating for as long as we want it to.
*/
import java.awt.*;
import CSLib.*;
public class SuffixLoop2
{
	public void doIt()
	{
		//KEEP REPEATING THE FOLLOWING
		//UNTIL THE USER SAYS STOP
		InputBox in = new InputBox();
		in.setPrompt ("How many suffixes do you want to process? ");
		int n = in.readInt(); //Get the number from the user
		
		for (int counter=1; counter<=n; counter++)
		{
			//INPUT SECTION
			in = new InputBox();
			
			in.setLocation (150, 150);	//Moves the InputBox over
							//to make the OutputBox easier to see
			Font myFont = new Font ("Serif", Font.ITALIC+Font.BOLD, 24);
			in.setFont (myFont);
			in.setBackground (Color.yellow);
			in.setForeground (Color.red);
			in.setPrompt("Please type in a number"
		 		+ " between 0 and 100.");
		 	int number = in.readInt();
		 	String suffix=" ";
		 
			//CALCULATION SECTION
			if (number==11||number==12||number==13)
				suffix = "th";
			else //take advantage of the pattern
			{
				switch (number % 10)
				{
					case 1:		suffix = "st";
							break;
							
					case 2:		suffix = "nd";
							break;
							
					case 3:		suffix = "rd";
							break;
							
					default:	suffix = "th";
				}//end switch
			}//end else
		
			//OUTPUT SECTION
			OutputBox out = new OutputBox("Add Suffixes");
			out.setSize (350, 150);
			out.println ("You gave me the number "
				+ number + ".\n\n\n");
			out.println ("That corresponds to the"
				+ " adjective " + number
				+ suffix + ".");
		}//end while
		Timer.pause(4000);
		System.exit(0);
	}
}
