PROGRAMMING AND CODE


Assignemnt #37

Code

/// Name: Justin Li
/// Period 7
/// Program Name: How Old Are You
/// File Name: HowOldAreYou.java
/// Date Finished: 10/28/15

import java.util.Scanner;

class HowOldAreYou {
  
    public static void main(String[]args) {
      
        Scanner keyboard = new Scanner(System.in);
        
        String name;
        int age;
        
        System.out.println("What is you name?:");
        name = keyboard.next();
        
        System.out.println("Hello " + name + ", How old are you?:");
        age = keyboard.nextInt();

        if ( age < 16 )
        {
        System.out.println("You can't drive.");
        }
        else if ( age == 16 || age == 17 )
        {
        System.out.println("You can drive but not vote.");
        }
        else if ( age >= 18 && age <= 24 )
        {
        System.out.println("You can vote but not rent a car.");
        }
        else if ( age >= 25 )
        {
        System.out.println("You can do pretty much anything.");
        }
    }
}
    

Picture of the output

Assignment 1