Assignemnt #51 Alphabetical
Code
///Name: Joshua Pell
///Period: 6
///Project Name: Alphabetical
///File Name: alphabetical.java
///Date: 11/18/2015
import java.util.Scanner;
public class alphabetical
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int n1,n2,n3,n4;
String name;
System.out.println("What is your last name?");
name = keyboard.next();
n1 = name.compareTo("Carswell");
if (n1 <= 0)
{
System.out.println("you don't have to wait long");
}
else
{
n2 = name.compareTo("Jones");
if (n2 <= 0)
{
System.out.println("that's not bad");
}
else
{
n3 = name.compareTo("Smith");
if (n3 <= 0)
{
System.out.println("looks like a bit of a wait");
}
else
{
n4 = name.compareTo("yong");
if (n4 <= 0)
{
System.out.println("it's gonna be a while");
}
else
{
System.out.println("not going anywhere for a while?");
}
}
}
}
}
}
Picture of the output