Assignemnt #37
Code
///Colin Hinton
///5th period
///How Old Be You
///HowOldBeYou.java
///10/1/2015
import java.util.Scanner;
class HowOldBeYou
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
int age;
String name;
System.out.print("Hey what is your name? ");
name = keyboard.next();
System.out.print(" ok, " + name + " , how old are you? ");
age = keyboard.nextInt();
if (age < 16)
{
System.out.println( "You can't drive " + name);
}
else if (age == 16)
{
System.out.println(" You can drive but not vote " + name);
}
else if (17 == age)
{
System.out.println( "You can drive but not vote " + name);
}
else if (24 >= age)
{
System.out.println( "You can vote but not rent a car " + name);
}
else if (age >= 25)
{
System.out.println( "You can do pretty much anything legal " + name);
}
}
}
Picture of the output