Advertisement
tchenkov

L07u06_NumberInRange1to100

Feb 21st, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 20.02.2017 г..
  7.  */
  8. public class u06_NumberInRange1to100 {
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.    
  12.         System.out.print("Еnter a number in the range [1...100]: ");
  13.         int num = Integer.parseInt(scan.nextLine());
  14.         while (num < 1 || 100 < num){
  15.             System.out.println("Invalid number!");
  16.             num = Integer.parseInt(scan.nextLine());
  17.             System.out.print("Еnter a number in the range [1...100]: ");
  18.         }
  19.         System.out.printf("The number is: %d", num);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement