Assignment #51 and Alphabetical Order
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Alphabetical Order
/// File Name: AlphabeticalOrder.java
/// Date Finished: 10/5/2015
import java.util.Scanner;
public class AlphabeticalOrder
{
public static void main( String[] args )
{
String name;
Scanner keyboard = new Scanner(System.in);
System.out.print( "What's your last name? " );
name = keyboard.next();
int i = name.compareTo("Carswell");
if ( i <= 0 )
{
System.out.println( "You don't have to wait long, " + name + "." );
}
else
{
int j = name.compareTo("Jones");
if ( j <= 0 )
{
System.out.println( "That's not bad, " + name + "." );
}
else
{
int k = name.compareTo("Smith");
if ( k <= 0 )
{
System.out.println( "Looks like a bit of a wait, " + name + "." );
}
else
{
int l = name.compareTo("Young");
if ( l <= 0 )
{
System.out.println( "It's gonna be a while, " + name + "." );
}
else
{
System.out.println( "Not going anywhere for a while, " + name + "?" );
}
}
}
}
}
}
Picture of the output