Advertisement
MrDoyle

How Old Are You?

Sep 18th, 2020 (edited)
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner (System.in);
  7.  
  8.         System.out.print("Hey, what's your name? ");
  9.         String name = input.nextLine();
  10.  
  11.         System.out.print("OK " + name + ", how old are you? ");
  12.         int age = input.nextInt();
  13.  
  14.         if (age < 16 ) {
  15.             System.out.println("You can't drive.");
  16.         }
  17.         if (age < 18 ){
  18.             System.out.println("You can't vote");
  19.         }
  20.         if ( age < 25) {
  21.             System.out.println("You can't rent a car.");
  22.         }
  23.         if (age >= 25) {
  24.             System.out.println("You can do anything that's legal.");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement