IP class in java

On-campus and online computer science courses to Learn the basic concepts of Computer Science.This tutorial will cover c ,c++, java, data structure and algorithm,computer graphics,microprocessor,analysis of algorithms,Digital Logic Design and Analysis,computer architecture,computer networks,operating system.
code in Java:
import java.io.*;
public class IPClass {
 
 public static void main(String args[]) throws IOException
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Please enter the IP address");
  String ip = br.readLine();
  String firstByte = ip.substring(0, ip.indexOf('.'));
  int fB = Integer.parseInt(firstByte);
  if(fB < 128)
   System.out.println("Class A");
  else if(fB < 192)
   System.out.println("Class B");
  else if(fB < 224)
   System.out.println("Class C");
  else if(fB < 240)
   System.out.println("Class D");
  else if(fB < 256)
   System.out.println("Class E");
 }

}
output:-
Please enter the IP address
224.1.23.14
Class D
--------------------------------

0 comments: