// Variation of Stars1 that draws various lines and boxes. This // version uses parameterized methods to eliminate redundancy. public class Stars2 { public static void main(String[] args) { line(13); line(7); line(35); box(10, 5); box(5, 6); } // Draws a line of stars of the given length. public static void line(int numStars) { for (int star = 1; star <= numStars; star++) { System.out.print("*"); } System.out.println(); } // Draws a box of stars of the given width and height. public static void box(int width, int height) { line(width); for (int line = 1; line <= height - 2; line++) { System.out.print("*"); for (int space = 1; space <= width - 2; space++) { System.out.print(" "); } System.out.println("*"); } line(width); } }