galinyotsev123

ProgBasicsJavaBook7.1ComplexLoop06numberInRange1to100

Jan 14th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E06numberInRange1to100 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int num = Integer.parseInt(scanner.nextLine());
  8.  
  9. while (num < 1 || num > 100) {
  10. System.out.println("Invalid number!");
  11. num = Integer.parseInt(scanner.nextLine());
  12.  
  13. }
  14. System.out.println("The number is: " + num);
  15.  
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment