Advertisement
veronikaaa86

10. Invalid Number

Jul 17th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. package advancedConditionalStatements;
  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. // ако е в диапазона [100…200] или е 0
  12. boolean isValid = (num >= 100) && (num <= 200) || num == 0;
  13.  
  14. if (!isValid) {
  15. System.out.println("invalid");
  16. }
  17. }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement