public class LinesAndBoxes { public static void main(String[] args) { drawLine(13); drawLine(7); drawLine(35); drawBox(10, 3); drawBox(5, 4); } public static void drawLine(int times) { repeat("*", times); System.out.println(); } public static void drawBox(int w, int h) { drawLine(w); // print the middle for (int height = 1; height <= h - 2; height++) { System.out.print("*"); repeat(" ", w - 2); System.out.println("*"); } drawLine(w); } public static void repeat(String ch, int count) { for (int i = 1; i <= count; i++) { System.out.print(ch); } } }