desislava_topuzakova

10. Invalid Number

Jun 19th, 2021
850
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class InvalidNumber_10 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int number = Integer.parseInt(scanner.nextLine());
  7.         //валидно -> [100; 200] или е 0
  8.         //(number >= 100 и number <= 200) Или number == 0
  9.         boolean isValid = (number >= 100 && number <= 200) || number == 0;
  10.         //isValid = true -> числото е валидно
  11.         //isValid = false -> числото НЕ Е валидно
  12.        if(!isValid) {
  13.            System.out.println("invalid");
  14.        }
  15.     }
  16. }
RAW Paste Data