Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import static java.lang.System.*;
- import java.util.Scanner;
- import java.lang.Math;
- public class newProj {
- public static void main (String str []) throws IOException {
- Scanner scanner = new Scanner(System.in);
- int a;
- int b;
- int c;
- int d;
- int x;
- boolean e;
- boolean f;
- boolean g;
- boolean h;
- System.out.println("Please enter the first octet.");
- a = scanner.nextInt();
- System.out.println("Please enter the second octet.");
- b = scanner.nextInt();
- System.out.println("Please enter the third octet.");
- c = scanner.nextInt();
- System.out.println("Please enter the fourth octet.");
- d = scanner.nextInt();
- x = 1;
- if(a >= 0 && a <= 255) {
- }
- else {
- System.out.println("Octet 1 is incorrect");
- x = 0;
- }
- if(b >= 0 && b <= 255) {
- }
- else {
- System.out.println("Octet 2 is incorrect");
- x = 0;
- }
- if(c >= 0 && c <= 255) {
- }
- else {
- System.out.println("Octet 3 is incorrect");
- x = 0;
- }
- if(d >= 0 && d <= 255) {
- }
- else {
- System.out.println("Octet 4 is incorrect");
- x = 0;
- }
- if(x != 0) {
- System.out.println("IP Address: " + a + "." + b + "." + c + "." + d);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement