An IP address consists of four numbers from 0 to 255, inclusive, divided by the dots. For example, 127.0.0.1 is a valid IP address, but 256.0.0.1 and 127.0.1 are invalid IP addresses.
For a given string output "YES" if this string is a valid IP address, otherwise output "NO".
Regexes in programs
Check IP address
Report a typo
Sample Input 1:
127.0.0.1Sample Output 1:
YESSample Input 2:
256.0.0.1Sample Output 2:
NOSample Input 3:
127.0.1Sample Output 3:
NOSample Input 4:
192.168.123.231Sample Output 4:
YESSample Input 5:
-1.0.0.1Sample Output 5:
NOSample Input 6:
127.0.0.1.Sample Output 6:
NOWrite a program in Java 17
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// start coding here
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.