Answer:
import java.util.Scanner;
public class HollowSquare
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int size;
System.out.print("Enter the size : ");
size = scan.nextInt();
if(size>=1 && size<=20)
{
for(int i=0; i<size; i++)
{
for(int j=0; j<size; j++)
{
if(i==0 || j==0 || i==size-1 || j==size-1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
else
System.out.println("Invalid size.");
}
}
Answer:
May this help you l think
Answer:
Explanation:
Given a class C IP address
195.1.1.0
Existing mask is 255.255.255.0
We want to have 12 hosts on 10 subnets.
A class C address has 8 bits of the host which will give, n=8
2ⁿ - 2 = 254 hosts
Current mask= 255.255.255.0
Bits needs for 10 subnets
2ⁿ = 10, n = 4bits
n = 4 = 2⁴ = 16 possible subnets
Now, bit needed for 12host, n =4bits
2⁴-2 = 14 possible host,
Total of 8 bits needed so therefore we can use as 4bits for the subnet.
So we could have
4 bit subnet and 4 bits hosts
11110000 = 240decimals
Final possible masks is
255.255.255.240