Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Advanced_Loops - created by borkins on 2017-04-08.
- */
- import java.util.Scanner;
- public class _06_NumberInRange_1_100
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int num;
- while (true)
- {
- System.out.print("Enter a number in the range [1...100]: ");
- num = Integer.parseInt(console.nextLine());
- if (num > 0 && num <= 100) break;
- System.out.println("Invalid number!");
- }
- System.out.println("The number is: " + num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment