Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P01numberInRange1to100 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Еnter a number in the range [1...100]: ");
- int commandNumber = Integer.parseInt(scanner.nextLine());
- while(commandNumber < 1 || commandNumber > 100){
- System.out.println("Invalid number!");
- System.out.print("Еnter a number in the range [1...100]: ");
- commandNumber = Integer.parseInt(scanner.nextLine());
- }
- System.out.println("The number is: " + commandNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment