-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPAddress.java
More file actions
38 lines (33 loc) · 784 Bytes
/
IPAddress.java
File metadata and controls
38 lines (33 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.*;
class IPAddress
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String address;
System.out.println("enter the ip adddress");
address=sc.next();
int IPVAL=0;
String classLevel="";
for(int i=0;i<3;i++)
{
int temp=address.charAt(i);
if(temp=='.')
break;
IPVAL=((IPVAL*10)+(temp-48));
}
if(IPVAL<128)
classLevel="A";
else if(IPVAL<192)
classLevel="B";
else if(IPVAL<224)
classLevel="C";
else if(IPVAL<240)
classLevel="D";
else if(IPVAL<256)
classLevel="E";
else
classLevel="invalid network ip";
System.out.print("Class:"+classLevel);
}
}