Please look at my JAVA code. I need the output to be a HOLLOW BOX consisting of * with the size being user defined. The box in my output however is solid. It should look something like this:
Please look at my JAVA code. I need the output to be a HOLLOW BOX consisting of * with the size being user defined. The box in my output however is solid. It should look something like this:
* * * * *
* *
* *
* *
* * * * *
import java.util.*;
public class question5
{
public static void main(String []args)
{
int size;
Scanner kb = new Scanner(System.in);
//user input
System.out.println("Please enter a number: ");
size = kb.nextInt();
//outer loop
for(int i=0; i<size; i++)
{
//inner loop to size
for(int j=0; j<size; j++)
System.out.print("*");
System.out.print("\n");
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images