Assignemnt #51 Alphabetical Order
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Alphabetical Order
///File Name: ABC.java
import java.util.Scanner;
public class ABC
{
public static void main( String[] args)
{
Scanner momo= new Scanner(System.in);
String name;
System.out.println ( " What is your last name? " );
name=momo.next();
if (name.compareTo("Carswell") < 0)
{
System.out.println( "You don't have to wait that long" );
}
else if (name.compareTo("Carswell") >= 0 && name.compareTo("Jones") < 0 )
{
System.out.println( " not bad" );
}
else if (name.compareTo("Jones") >= 0 && name.compareTo("Smith") < 0)
{
System.out.println( "looks like a bit of a wait" + name + "." );
}
else if (name.compareTo("Smith") >= 0 && name.compareTo("Young") < 0)
{
System.out.println( " gonna be a while" );
}
else if (name.compareTo("Young") >= 0)
{
System.out.println( "not going anwhere for a while" );
}
}
}
Picture of Output