Assignemnt # Alphabetical Order
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: AlphabeticalOrder
/// File Name: AlphabeticalOrder.java
/// Date Finished: 11/30/2015
import java.util.Scanner;
public class AlphabeticalOrder {
public static void main (String [] args) {
Scanner s = new Scanner(System.in);
String name;
int Carswell, Jones, Smith, Young;
System.out.print("What's your last name? ");
name = s.nextLine();
Carswell = name.compareToIgnoreCase("Carswell");
Jones = name.compareToIgnoreCase("Jones");
Smith = name.compareToIgnoreCase("Smith");
Young = name.compareToIgnoreCase("Young");
if (Carswell <= 0)
System.out.println("You don't have to wait long, " + name);
else if (Jones <= 0)
System.out.println("That's not bad, " + name);
else if (Smith <= 0)
System.out.println("Looks like a bit of a wait, " + name);
else if (Young <= 0)
System.out.println("It's gonna be a while, " + name);
else
System.out.println("You're not going anywhere for a while, " + name);
}
}
Picture of the output