import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class IpRange {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String str1="192.168.1.101";
String str2="192.168.1.199";
int[] p1 = new int[4];
int[] p2 = new int[4];
int[] p3 = new int[4];
System.out.println("Enter valid ip address");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str3=br.readLine();
String[] s1 =str1.toString().split("\\.");
String[] s2 =str2.toString().split("\\.");
String[] s3 =str3.toString().split("\\.");
// p1[0] = Integer.parseInt(s1[0]);
//
// p1[1] = Integer.parseInt(s1[1]);
p1[2] = Integer.parseInt(s1[2]);
p1[3] = Integer.parseInt(s1[3]);
// p2[0] = Integer.parseInt(s2[0]);
//
// p2[1] = Integer.parseInt(s2[1]);
p2[2] = Integer.parseInt(s2[2]);
p2[3] = Integer.parseInt(s2[3]);
// p3[0] = Integer.parseInt(s3[0]);
//
// p3[1] = Integer.parseInt(s3[1]);
p3[2] = Integer.parseInt(s3[2]);
p3[3] = Integer.parseInt(s3[3]);
if ((p1[2] < p3[2] && p2[2] > p3[2])&&(p1[3] < p3[3] && p2[3] > p3[3]) )
{
System.out.println("valid ip address");
}
else
{
System.out.println("invalid ip address");
}
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class IpRange {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String str1="192.168.1.101";
String str2="192.168.1.199";
int[] p1 = new int[4];
int[] p2 = new int[4];
int[] p3 = new int[4];
System.out.println("Enter valid ip address");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str3=br.readLine();
String[] s1 =str1.toString().split("\\.");
String[] s2 =str2.toString().split("\\.");
String[] s3 =str3.toString().split("\\.");
// p1[0] = Integer.parseInt(s1[0]);
//
// p1[1] = Integer.parseInt(s1[1]);
p1[2] = Integer.parseInt(s1[2]);
p1[3] = Integer.parseInt(s1[3]);
// p2[0] = Integer.parseInt(s2[0]);
//
// p2[1] = Integer.parseInt(s2[1]);
p2[2] = Integer.parseInt(s2[2]);
p2[3] = Integer.parseInt(s2[3]);
// p3[0] = Integer.parseInt(s3[0]);
//
// p3[1] = Integer.parseInt(s3[1]);
p3[2] = Integer.parseInt(s3[2]);
p3[3] = Integer.parseInt(s3[3]);
if ((p1[2] < p3[2] && p2[2] > p3[2])&&(p1[3] < p3[3] && p2[3] > p3[3]) )
{
System.out.println("valid ip address");
}
else
{
System.out.println("invalid ip address");
}
}
}
No comments:
Post a Comment