Assignemnt #51 and Alphabetical Order
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Alphabetical Order
///File Name: AlphabeticalOrder
///Date Finished: 10/29/15
import java.util.Scanner;
public class AlphabeticalOrder
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String lastName;
System.out.print( "What's your last name? " );
lastName = keyboard.next();
int c = "Carswell".compareTo(lastName);
int j = "Jones".compareTo(lastName);
int s = "Smith".compareTo(lastName);
int y = "Young".compareTo(lastName);
if ( c >= 0 )
{
System.out.println( "You don't have to wait long." );
}
else if ( j >= 0 )
{
System.out.println( "That's not bad." );
}
else if ( s >= 0 )
{
System.out.println( "Looks like a bit of a wait." );
}
else if ( y >= 0 )
{
System.out.println( "It's gonna be a while." );
}
else if ( y < 0 )
{
System.out.println( "Not going anywhere for a while?" );
}
}
}
Picture of the output