Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner; // Gets input from user.
  3. public class MyClass {
  4. public static void main(String[] args) { // All java programs start with main.
  5. Scanner age = new Scanner(System.in);
  6. try {
  7. int agein = age.nextInt();
  8. if(agein < 16){
  9. System.out.println("To young!");
  10. } else if (agein >= 16) {
  11. System.out.println("Welcome!");
  12. }
  13. } catch (InputMismatchException e){
  14. System.out.println("That's not a number!");
  15. }
  16.  
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement