Assignemnt #37 How Old Are You, Specifically?
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: HowOldAreYouAgain
/// File Name: HowOldAreYouAgain.java
/// Date Finished: 10/1/2015
import java.util.Scanner;
public class HowOldAreYouAgain
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
String name;
double age;
System.out.print("Hey, what's your name? (Sorry, I keep forgetting.) ");
name = keyboard.next();
System.out.print("Ok, " + name + " how old are you? " );
age = keyboard.nextDouble();
if (age < 16)
{
System.out.println("You can't drive.");
}
else if (age < 18)
{
System.out.println("You can't vote, but you can drive!");
}
else if (age < 25)
{
System.out.println("You can't rent a car, but you can vote and drive!");
}
else if (age >= 25)
{
System.out.println("You can do anything that's legal.");
}
}
}
Picture of the output