//File:	Suffix.java
/*
ANALYSIS OF THE PROBLEM
INPUT:	integer between 0 and 100
COMPUTATION:	add appropriate suffix to number
		Ex. 4	4th
		Ex. 2	2nd
		Ex. 3	3rd
		Ex. 1	1st
OUTPUT:	output the input data and the results

Where do I begin?

if (number is 11, 12, or 13)
	do it separately
else
	take advantage of the pattern
	switch (number)
	{
		case 0: case 10: case 20: case 30: etc
			add "th"
		case 1:case 21:case 31:case 41: etc
			add "st"
		case 2: case 22: case 32: case 42: etc
			add "nd"
			etc.
		NOT TOO CREATIVE
	}

MORE CREATIVE
switch (number % 10) ==> divide by 10 and take the remainder
{
	case 0:	suffix = "th"; ==> this gets 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, and 100!!!!
	case 1: suffix = "st"; ==> this gets 1, 21, 31, 41, 51, 61, 71, 81,  and 91
	etc.
}

I think I've got it!	
*/
import CSLib.*;
public class Suffix
{
	public void doIt()
	{
		//INPUT SECTION
		InputBox in = new InputBox();
		in.setPrompt("Please type in a number"
		 	+ " between 0 and 100.");
		int number = in.readInt();
		
		String suffix=" ";	//If you don't INITIALIZE this, you may get
					//error message
		 
		//CALCULATION SECTION
		if (number==11||number==12||number==13) //The ODDBALLS
			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");
		
		//All those \n's give you carriage returns or extra spacing
		out.println ("You gave me the number "
			+ number + ".\n\n\n");
		
		out.println ("That corresponds to the"
			+ " adjective " + number
			+ suffix + ".");
	}//end doIt()
}
