Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- final int MIN_VALUE = 0;
- final int MAX_VALUE = 100;
- boolean isIncorrect;
- Scanner scanner = new Scanner(System.in);
- int number = 0;
- do {
- isIncorrect = false;
- try {
- number = Integer.parseInt(scan.nextLine());
- } catch (NumberFormatException e) {
- isIncorrect = true;
- System.out.println("Type error!");
- }
- if (!isIncorrect && (number < MIN_VALUE || number > MAX_VALUE)) {
- isIncorrect = true;
- System.out.println("Range error!");
- }
- } while (isIncorrect);
- scanner.close();
- System.out.print(number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement