Assignemnt #51 Alphabetical Order
Code
///Tyler Hart
///period 5
///Alphabetical Order
///alpha.java
///10/29/2015
import java.util.Scanner;
public class alpha
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int d1,d2,d3,d4;
String name;
System.out.println("What is your last name?");
name = keyboard.next();
d1 = name.compareTo("Carswell");
if (d1 <= 0)
{
System.out.println("you don't have to wait long");
}
else
{
d2 = name.compareTo("Jones");
if (d2 <= 0)
{
System.out.println("that's not bad");
}
else
{
d3 = name.compareTo("Smith");
if (d3 <= 0)
{
System.out.println("looks like a bit of a wait");
}
else
{
d4 = name.compareTo("yong");
if (d4 <= 0)
{
System.out.println("it's gonna be a while");
}
else
{
System.out.println("not going anywhere for a while?");
}
}
}
}
}
}
Picture of the output