Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner (System.in);
- String name;
- int age;
- String drive = "You can't drive";
- String vote = "You can't vote";
- String rent = "You can't rent a car";
- String legal = "You can do anything that's legal";
- System.out.print("Hey, what's your name? ");
- name = keyboard.next();
- System.out.print("Ok " + name + ", how old are you? ");
- age = keyboard.nextInt();
- if (age < 16){
- System.out.println(drive + ", " + rent + " and " + vote);
- } else if (age < 18){
- System.out.println(vote + ", " + rent);
- } else if (age < 25){
- System.out.println(rent);
- } else {
- System.out.println(legal);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement