Professional Documents
Culture Documents
Subnet
Subnet
NO:7
IMPLEMENTATION OF SUBNETTING
AIM:
To implement the subnetting program in java to find the equivalent binary number for the
given IP addresses and calculates the subnet mask.
ALGORITHM:
1. Include the header files and declare the variables.
2. Create the java class in the name of Subnet.
3. Get the IP address of the system and produce the binary equivalent of the given IP.
4. The subnet mask used to distinguish the network address and host address.
5. Binary equivalent of IP address and subnet mask calculated and displayed.
6. Stop the execution after getting the result.
PROGRAM:
import java.io.*;
import java.util.Scanner;
class Subnet{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.print("Enter the ip address: ");
String ip = sc.nextLine();
String split_ip[] = ip.split("\\.");
String split_bip[] = new String[4]; String bip = "";
for(int i=0;i<4;i++)
{
split_bip[i] = appendZeros(Integer.toBinaryString(Integer.parseInt(split_ip[i]))); bip +=
split_bip[i];
}
RESULT:
Thus the program for subnetting in java was successfully executed