Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. import java.util.Scanner;
  2. class Example2 {
  3.     public static void main(String args[]) {
  4.  
  5.         Scanner sc = new Scanner(System.in);
  6.         int age = 0;
  7.         boolean finish = false;
  8.         while (finish == false) {
  9.             System.out.print("Input age:");
  10.             age = sc.nextInt();
  11.             if (age < 0 || age > 120) {
  12.                 System.out.println("Invalid");
  13.             } else {
  14.                 System.out.println("Good");
  15.                 finish = true;
  16.             }
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement