// Helene Martin, CSE 142 // Prints shapes made up of ASCII stars. // goal: demonstrates the power of parameters for generalizing solutions to problems. public class Stars2 { public static void main(String[] args) { line(13); line(7); line(35); box(10, 5); box(5, 6); //box(100, 23); } // prints any String str size times // (for ex: repeat(12, "-") prints 12 dashes) public static void repeat(int size, String str) { for (int i = 1; i <= size; i++) { System.out.print(str); } } // prints a line of size stars followed by a new line public static void line(int size) { repeat(size, "*"); System.out.println(); } // prints a box of size width x height public static void box(int width, int height) { line(width); for (int line = 1; line <= height - 2; line++) { System.out.print("*"); repeat(width - 2, " "); System.out.println("*"); } line(width); } }