Untitled
unknown
plain_text
4 years ago
1.1 kB
5
Indexable
/* Lesson 4 Coding Activity Question 3 */ import java.util.Scanner; public class U3_L4_Activity_Three{ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Please enter the first octet:"); int a = input.nextInt(); System.out.println("Please enter the second octet:"); int b = input.nextInt(); System.out.println("Please enter the third octet:"); int c = input.nextInt(); System.out.println("Please enter the fourth octet:"); int d = input.nextInt(); if (a < 0 || a > 255 ){ System.out.println("Octet 1 is incorrect"); } if (b < 0 || b > 255 ){ System.out.println("Octet 2 is incorrect"); } if (c < 0 || c > 255 ){ System.out.println("Octet 3 is incorrect"); } if (d < 0 || d > 255 ){ System.out.println("Octet 4 is incorrect"); }else if (!(a < 0 || a > 255) && !(b < 0 || b > 255) && !(c < 0 || c > 255) && !(d < 0 || d > 255)){ System.out.println("IP Address: " + a + "." + b + "." + c + "." + d); } } }
Editor is loading...