Assignemnt #51
Code
/// Name: Sam Menar
/// Period: 6
/// Program Name: AlphabeticalOrder
/// File Name: AlphabeticalOrder.java
/// Date Finished: 11/18/2015
import java.util.Scanner;
public class AlphabeticalOrder
{
public static void main( String[]args )
{
Scanner keyboard = new Scanner(System.in);
String name;
System.out.print( "What's you last name? " );
name = keyboard.next();
if (name.compareTo("Carswell") <0 )
{
System.out.println( "You don't have to wait long" );
}
else if (name.compareTo("Jones") <0 )
{
System.out.println( "That's not bad" );
}
else if (name.compareTo("Smith") <0 )
{
System.out.println( "looks like a bit of a wait" );
}
else if (name.compareTo("Young") <0 )
{
System.out.println( "It's gonna be a while" );
}
else
{
System.out.println( "not going anywhere for a while?" );
}
}
}
Picture of the output