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