veronikaaa86

10. Invalid Number

Jan 21st, 2023
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. package nestedConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P10InvalidNumber {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int num = Integer.parseInt(scanner.nextLine());
  10.  
  11.         boolean isValid = num >= 100 && num <= 200 || num == 0;
  12.  
  13.         if (!isValid) {
  14.             System.out.println("invalid");
  15.         }
  16.     }
  17. }
  18.  
Add Comment
Please, Sign In to add comment