Assignment 51, Alphabetical Order
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: ALphabetical Order
///File Name: AphabeticalOrder.java
///Date Finshed: 12/1/15
import java.util.Scanner;
public class AlphabeticalOrder
{
public static void main (String [] args)
{
Scanner siri= new Scanner(System.in);
String last;
System.out.print("What's your last name? ");
last = siri.next();
int a = last.compareTo("Carwell");
int b = last.compareTo("Jones");
int c = last.compareTo("Smith");
int d = last.compareTo("Young");
if (a <= 0)
{
System.out.println("You don't have to wait long");
}
if (a > 0)
if (b <= 0)
{
System.out.println("That's not a bad wait");
}
if (b > 0)
if (c <= 0)
{
System.out.println("That's a bit of a wait");
}
if (c > 0)
if (d > 0)
System.out.println("You have a long time to wait");
if (d <= 0 && c > 0)
System.out.println("You have a while to wait");
}
}
Picture of the output