Assignemnt 34 and How Old Are You
Code
///Name: Xinting Chen
///Period: 5
///Program Name: How Old Are You
///File Name: HowOldAreYou.java
///Date Finished: 10/15/15
import java.util.Scanner;
public class HowOldAreYou
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String Name;
int Age;
System.out.println("Hey, What is your name?");
Name = keyboard.next();
System.out.println("Ok "+Name+", how old are you?");
Age = keyboard.nextInt();
if ( Age < 16 )
{
System.out.println("You can't drive, "+Name);
}
if ( Age < 18 )
{
System.out.println("You can't vote, "+Name);
}
if ( Age < 25 )
{
System.out.println("You can't rent a car, "+Name);
}
if ( Age >= 25 )
{
System.out.println("You can do anything legal now "+Name);
}
}
}
Picture of the output