If statement part 2 #51 (I dislike being Near last)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name:Alphabetical Order
/// File Name: AlphabeticalOrder.java
/// Date Finished: 11/13/2015
import java.util.Scanner;
public class AlphabeticalOrder {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
String name;
System.out.print("What's your last name? ");
name = input.nextLine();
if (name.compareTo("Carsewll") <0) {
System.out.println("you don't have to wait long. ");
}else if (name.compareTo("Jones") <0) {
System.out.println("that's not bad. ");
}else if (name.compareTo("Smith") <0) {
System.out.println("looks like a bit of a wait." );
}else if (name.compareTo("Young") <0) {
System.out.println("it's gonna be a while. ");
}else {
System.out.println("no going anywhere for a while? ");
}
}
}
Picture of the output