Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. import java.io.*;
  2. import static java.lang.System.*;
  3. import java.util.Scanner;
  4. import java.lang.Math;
  5.  
  6. public class newProj {
  7.          public static void main (String str []) throws IOException {
  8.        
  9.         Scanner scanner = new Scanner(System.in);
  10.      
  11.         int a;   
  12.         int b; 
  13.         int c;   
  14.         int d;
  15.         int x;
  16.         boolean e;
  17.         boolean f;
  18.         boolean g;
  19.         boolean h;
  20.  
  21.        
  22.         System.out.println("Please enter the first octet.");     
  23.         a = scanner.nextInt();
  24.         System.out.println("Please enter the second octet.");    
  25.         b = scanner.nextInt();
  26.         System.out.println("Please enter the third octet.");     
  27.         c = scanner.nextInt();
  28.         System.out.println("Please enter the fourth octet.");    
  29.         d = scanner.nextInt(); 
  30.        
  31.        x = 1;
  32.        
  33.        if(a >= 0 && a <= 255) {
  34.        }
  35.        else {
  36.            System.out.println("Octet 1 is incorrect");
  37.             x = 0;
  38.        }
  39.        
  40.        if(b >= 0 && b <= 255) {
  41.        }
  42.        else {
  43.            System.out.println("Octet 2 is incorrect");
  44.             x = 0;
  45.        }
  46.        
  47.        if(c >= 0 && c <= 255) {
  48.        }
  49.        else {
  50.            System.out.println("Octet 3 is incorrect");
  51.             x = 0;
  52.        }
  53.        
  54.        if(d >= 0 && d <= 255) {
  55.        }
  56.        else {
  57.            System.out.println("Octet 4 is incorrect");
  58.             x = 0;
  59.        }
  60.        
  61.      
  62.        if(x != 0) {
  63.            System.out.println("IP Address: " + a + "." + b + "." + c + "." + d);
  64.        }
  65.          }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement