Assignemnt #37: How Old Are You, Specifically
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: HowOldAreYouSpecifically
/// File Name: HowOldAreYouSpecificallys.java
/// Date Finished: 10/15/2015
import java.util.Scanner;
public class HowOldAreYouSpecifically
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String name;
int age;
System.out.print("What's your name? ");
name = keyboard.next();
System.out.print("How old are you, " + name + "? ");
age = keyboard.nextInt();
if (age < 16)
{
System.out.println("You can't drive.");
}
else if (age < 18)
{
System.out.println("You can drive but not vote.");
}
else if (age < 25)
{
System.out.println("You can vote but not rent a car.");
}
else
{
System.out.println("You can do pretty much anything.");
}
}
}
Picture of the output