Assignment #34
Code
///Jack Newsom
///Period 5
///Program Name : HowOld
///filename: HowOld.java
//date completed 9/21/15
package ifStatements;
import java.util.Scanner;
public class HowOld {
public static void main(String[] args) {
Scanner oldbot = new Scanner(System.in);
int age;
String name;
System.out.println("Hello, what is your name? ");
name = oldbot.next();
System.out.println("Ok ," + name + ", how old are you? ");
age = oldbot.nextInt();
if ( age < 25)
{
System.out.println("You can't rent a car, " + name + ".");
if ( age < 18)
{
System.out.println("You can't vote, " + name + ".");
if ( age < 16)
{
System.out.println("You can't drive, " + name + ".");
}
}
}
if ( age >= 25)
{
System.out.println("You can do anything legal, " + name + ".");
}
}
}
Picture of the output