Assignemnt #34 How Old Are YOu
Code
/// Name: DeeJay Cerezo
/// Period: 7
/// Program Name: How Old Are You
/// File Name: HowOldAreYou.java
/// Date Finished: 10/22/2015
import java.util.Scanner;
class HowOldAreYou {
public static void main(String[]args) {
Scanner keyboard = new Scanner(System.in);
String name;
int age;
System.out.print("What is your name? ");
name = keyboard.next();
System.out.print("Hello " + name + ", how old are you? ");
age = keyboard.nextInt();
if ( age < 16 )
{
System.out.println("You cannot drive.");
}
if ( age < 18 )
{
System.out.println("You cannot vote.");
}
if ( age < 25 )
{
System.out.println("You cannot rent a car.");
}
}
}
Picture of the output