Assignment #37: How Old Are You, Specifically?
Code
/// Name: Kiran O'Farrell
/// Period: 7
/// Program name: How Old Are You, Specifically?
/// File Name: AgeConditionalsII.java
/// Date Finished: 9/2/15
import java.util.Scanner;
public class AgeConditionalsII {
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
int age;
String firstName, lastName;
System.out.print("What's your first name? ");
firstName = keyboard.next();
System.out.print("What's your last name? ");
lastName = keyboard.next();
System.out.print("OK, " + firstName + " " + lastName + ", how old are you? ");
age = keyboard.nextInt();
if (age < 13 )
{
System.out.println("You're too young to create a Facebook account.");
}
else if (age < 16 )
{
System.out.println("You can create a Facebook account, but you're too young to drive.");
}
else if (age < 18 )
{
System.out.println("You can drive, but you're too young to vote.");
}
else if (age < 21 )
{
System.out.println("You can vote, but you're too young to drink.");
}
else if (age < 25)
{
System.out.println("You can drink, but you're too young to rent a car.");
}
else
{
System.out.println("You have no more age limitations.");
}
}
}
Picture of the output