// Helene Martin, CSE 142 // Displays boxes and lines made of characters. Parameters reduce redundancy. public class Stars { public static void main(String[] args) { line(13); line(7); line(35); box(5, 10); box(6, 5); } // Prints str repated times times on a single line public static void repeat(String str, int times) { for (int i = 1; i <= times; i++) { System.out.print(str); } } // Prints a line of stars, goes to the next line public static void line(int stars) { repeat("*", stars); System.out.println(); } // Prints a rectangle of stars of size width x height public static void box(int height, int width) { line(width); for (int line = 1; line <= height - 2; line++) { System.out.print("*"); repeat(" ", width - 2); System.out.println("*"); } line(width); } }