Assignment #37 How Old Are You, Specifically?
Code
///Name: Ian Grant
///Period:5
///Project Name: How Old Are You, Specifically?
///File Name:AgeOldv2.java
///10/20/15
import java.util.Scanner;
public class AgeOldv2
{
public static void main(String[] args)
{
String name;
int age;
Scanner keyboard =new Scanner(System.in);
System.out.print("Hey, what's your name? ");
name=keyboard.next();
System.out.print("Ok, "+name+", how old are you? ");
age=keyboard.nextInt();
if(age < 16)
{
System.out.print("You can't drive.");
}
else if(age < 17)
{
System.out.print("You can drive but not vote.");
}
else if(age < 24)
{
System.out.print("You can vote but not rent a car.");
}
else
{
System.out.print("You can do anything*!!!");
}
}
}
Output