//BoxMethods import javax.swing.JOptionPane; public class BoxMethods { public static void main( String[] args ) { int height,width, down; // Prompt the user to enter the height of the box String numString1 = JOptionPane.showInputDialog(null, "Enter the height of the box you wish to print:", "Input Number Window", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value height = Integer.parseInt(numString1); // Prompt the user to enter the width of the box String numString2 = JOptionPane.showInputDialog(null, "Enter the width of the box you wish to print:", "Input Number Window", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value width = Integer.parseInt(numString2); // print the top line of the box line_across (width); //print the sides of the box if (height > 2) { for (down=1; down <= height-2; down++) line_down(width); } //print the bottom line of the box line_across(width); //finish up System.out.print ("\n"); System.exit(0); } /* end of method main */ public static void line_down (int num) { int across; System.out.print("*"); for (across=1; across <=num-2; across++) System.out.print(" "); System.out.print("*\n"); } /* end of method line_down */ public static void line_across (int num) { int across; if (num > 0) { for (across=1; across <= num; across++) System.out.print("*"); } System.out.print("\n"); } // end method line_across } // end of class BoxMethods