Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ConditionalStatementsAdvanced;
- import java.util.Scanner;
- public class InvalidNumber_10 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int number = Integer.parseInt(scanner.nextLine());
- //валидно -> [100;200] или = 0 -> print nothing
- //невалидно -> print invalid
- boolean isValid = (number >= 100 && number <= 200) || number == 0;
- //true -> валидно
- //false -> невалидно
- if (!isValid) {
- System.out.println("invalid");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment