Advertisement
RageDoc

drinkingage

Jul 13th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. //for Avery. Here's the code you wrote; that I RE-wrote in like a minute. You pig.
  2. import java.util.Scanner;
  3. public class drinkingage{
  4.     private static Scanner sc = new Scanner(System.in);
  5.     public static void
  6.     main(String... args){
  7.         scan();
  8.     }
  9.     public static void
  10.     scan(){
  11.         System.out.println("How old are you?");
  12.         String age = sc.nextLine();
  13.         decide(Integer.parseInt(age));
  14.         }
  15.     public static void
  16.     decide(int age){
  17.         if(age>=21)
  18.             System.out.println("You can drink! Cheers!");
  19.         else
  20.             System.out.println("Sorry, you cannot drink. " + (21 - age) + " more years!");
  21.         System.exit(0);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement