Assignment #51 and Alphabetical Order
Code
/// Name: Brendan Baird
/// Period: 6
/// Program Name: Alphabetical Order
/// File Name: AlphaOrder.java
/// Date Finished: 10/26/2015
import java.util.Scanner;
public class AlphaOrder
{
public static void main(String[] args)
{
String name;
Scanner keyboard = new Scanner(System.in);
System.out.print("What's your last name? ");
name = keyboard.next();
if (name.compareTo("Carswell") <= 0)
System.out.println("You don't have to wait long, " + name + ".");
else if (name.compareTo("Jones") <= 0)
System.out.println("That's not bad, " + name + ".");
else if (name.compareTo("Smith") <= 0)
System.out.println("Looks like it's a bit of a wait, " + name + ".");
else if (name.compareTo("Young") <= 0)
System.out.println("It's gonna be awhile, " + name + ".");
else
System.out.println("Not going anywhere for awhile, " + name + "?");
}
}
Picture of the output