Advertisement
veronikaaa86

06. Number in Range

Mar 18th, 2023
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. package nestedConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06NumberInRange {
  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 <= 100 && num != 0;
  12.         if (isValid) {
  13.             System.out.println("Yes");
  14.         } else {
  15.             System.out.println("No");
  16.         }
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement