desislava_topuzakova

10. Invalid Number

Apr 17th, 2021
719
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
  7.         //валидно -> [100, 200] или е 0
  8.         //невалидно -> обратното на валидно
  9.         int number = Integer.parseInt(scanner.nextLine());
  10.         boolean isValid = (number >= 100 && number <= 200) || number == 0;
  11.         //isValid -> true -> валидно
  12.         //isValid -> false -> невалидно
  13.         if(!isValid) {
  14.             System.out.println("invalid");
  15.         }
  16.     }
  17. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×