Assignment #51 Alphabetical Order
Code
/// Name: Lacey Reese
/// Period: 5
/// Program Name: AlphabeticalOrder
/// File Name: AlphabeticalOrderwqs2zd.java
/// Date Finished 11/17/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 your last name? " );
name = keyboard.next();
int a = name.compareTo("Carson");
int b = name.compareTo("Jacobs");
int c = name.compareTo("Sulley");
int d = name.compareTo("Yoliver");
if ( a <= 0 )
{
System.out.println( "Don't have to wait long!" );
}
else if ( b <= 0 )
{
System.out.println( "Not that bad." );
}
else if ( c <= 0 )
{
System.out.println( "Looks like a bit of a wait." );
}
else if ( d <= 0 )
{
System.out.println( "Lol it's gonna be a while." );
}
else
{
System.out.println( "You'll be here forever, just kidding just for a long long time. " );
}
}
}
Picture of the output
//