Assignment #46: Age Messages III
Code
/// Name: Kiran O'Farrell
/// Program Name: Age Conditionals III
/// File Name: AgeConditionalsIII.java
/// Date Completed: 11/28/15
import java.util.Scanner;
public class AgeConditionalsIII {
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
int age;
String name;
System.out.println("What's your name?");
name = keyboard.next();
System.out.println("How old are you, " + name + "?");
age = keyboard.nextInt();
if (age < 16) {
System.out.println("You can't drive, " + name + ".");
}
if (age >= 16 && age < 18) {
System.out.println("You can drive but you can't vote, " + name + ".");
}
if (age >= 18 && age < 21) {
System.out.println("You can vote but you can't drink, " + name + ".");
}
if (age >= 21 && age < 25) {
System.out.println("You can drink but you can't rent a car, " + name + ".");
}
if (age > 25) {
System.out.println("You have no age restrictions, " + name + ".");
}
}
}
Picture of the output