I'm trying to write a program that will produce a square/rectangle according to the user's dimensions. It must be hollow, i.e.
If the user inputs width 5 and height 5 then...
*****
* *
* *
* *
*****
However, it produces
****
****
****
****
What am I doing wrong?
import javax.swing.JOptionPane;
public class box
{
public static void main(String[] args)
{
int shapeWidth = (Integer.parseInt(JOptionPane.showInputDialog("Enter the value for the width of your shape")));
int shapeheight = (Integer.parseInt(JOptionPane.showInputDialog("Enter the value for the height of your shape")));
for (int i = 1; i < shapeheight; i++)
{
for (int j = shapeheight; j == shapeheight; j++)
{
for (int k = 1; k < shapeWidth; k++)
{
for (int l = shapeWidth; l == shapeWidth; l++)
{
if (i == 1 )
System.out.print('*');
else if (j == shapeheight)
System.out.print('*');
else if
(k == 1)
System.out.print('*');
else if (l == shapeWidth)
System.out.print('*');
else
System.out.print(' ');
}
}
}
System.out.println();
}
}
}