Assignemnt #51: Alphabetical Order
Code
/// Name: Cassie
/// Period: 6
/// Program Name: Alphabetical Order
/// File Name: alphaorder.java
/// Date Finished: 12/1/2015
import java.util.Scanner;
class alphaorder
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.print( "What is your last name? " );
String lastName = keyboard.next();
if ( lastName.compareTo("Carswell") <= 0 )
{
System.out.println( "You don't have to wait long." );
}
else if ( lastName.compareTo("Jones") <= 0 )
{
System.out.println( "That's not bad." );
}
else if ( lastName.compareTo("Smith") <= 0 )
{
System.out.println( "Looks like a bit of a wait." );
}
else if ( lastName.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