Assignment #51 Alphabetical Order
Code
/// Name: DeeJay Cerezo
/// Period: 7
/// Program Name: Alphabetical Order
/// File Name: Alpha.java
/// Date Finished: 12/1/2015
import java.util.Scanner;
class Alpha
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String lastName;
int a, b, c, d;
System.out.print( "What's your last name? " );
lastName = keyboard.next();
a = lastName.compareTo("Carswell");
if ( a <= 0 )
{
System.out.println( "You don't have to wait long " + lastName + "." );
}
else if ( a > 0 )
{
b = lastName.compareTo("Jones");
if ( b <= 0 )
{
System.out.println( "That's not bad " + lastName + "." );
}
else if ( b > 0 )
{
c = lastName.compareTo("Smith");
if ( c <= 0 )
{
System.out.println( "Looks like a bit of a wait " + lastName + "." );
}
else if ( c > 0 )
{
d = lastName.compareTo("Young");
if ( d <= 0 )
{
System.out.println( "It's going to be a while " + lastName + "." );
}
else if ( d > 0 )
{
System.out.println( "Not going anywhere for a while " + lastName + "." );
}
}}}
}
}
Picture of the output