ok now what i want out of this program is to be able to ask the user how large the height and width of the drawing should be. (i seem to have this down ok or at least i think i do)
i also want to be able to have it so that the program should accept only odd numbers, when the user asks for an even number, ask again. (i cannot seem to figure out this portion too well)
also i want draw a square of the desired size utilizing the “*” character for the boundaries of the box, a “@” for the very center of the box, and “\” for the remaining parts(i cant figure out where to place the portion of the loop for the @)
this is what i have so far for the code.....its messy and all but ah well
the only import i want in this is the java.swing so no scanner or array or anything
i dont even want the if...else in there but i dont know how to do it with just the for
import javax.swing.JOptionPane; public class ex7 { 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 = 1; j <= shapeWidth; j++) { if (i == 1 || i == shapeheight) System.out.print('*'); else if (j == 1 || j == shapeWidth) System.out.print('*'); else System.out.print('/'); } System.out.println(); } } }
really seem to be having a lot of trouble with this one