Assignment #34: How Old Are You?

Code

/// Name: Kiran O'Farrell
/// Period: 7
/// Program name: How Old Are You?
/// File Name: AgeConditionals.java
/// Date Finished: 9/28/15

import java.util.Scanner;

public class AgeConditionals {

    public static void main (String[] args) {
    
        Scanner keyboard = new Scanner(System.in);
        
        int age;
        String yourName;
        
        System.out.print("What's your name?");
        yourName = keyboard.next();
        
        System.out.print("OK, " + yourName + ", how old are you?");
        age = keyboard.nextInt();
        
        if (age < 16) {
        
        System.out.println("You can't drive, " + yourName + ".");
        
        }
        
        if (age < 18) {
        
        System.out.println("You can't vote, " + yourName + ".");
        
        }
        
        if (age < 21) {
        
        System.out.println("You can't drink, " + yourName + ".");
        
        }
        
        if (age < 25) {
        
        System.out.println("You can't rent a car, " + yourName + ".");
        
        }
        
        if (age > 25) {
        
        System.out.println("You can do anything that's legal, " + yourName + ".");
        
        }
        
    }
    
}
    

Picture of the output

Assignment 34