BubaLazi

p06_NumInRange1-100

Mar 9th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AdvancedLoops {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         System.out.print("Еnter a number in the range [1...100]:");
  8.         int n = Integer.parseInt(console.nextLine());
  9.  
  10.         while ( n < 1 || n > 100){
  11.             System.out.println("Invalid number!");
  12.             System.out.print("Еnter a number in the range [1...100]:");
  13.             n = Integer.parseInt(console.nextLine());
  14.  
  15.         }
  16.         System.out.println("The number is: " + n);
  17.  
  18.  
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment