Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.Scanner; // Gets input from user.
- public class MyClass {
- public static void main(String[] args) { // All java programs start with main.
- Scanner age = new Scanner(System.in);
- try {
- int agein = age.nextInt();
- if(agein < 16){
- System.out.println("To young!");
- } else if (agein >= 16) {
- System.out.println("Welcome!");
- }
- } catch (InputMismatchException e){
- System.out.println("That's not a number!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement