// Helene Martin, CSE 142 // Displays several lines and boxes made of ASCII characters. // (parameters are used to reduce redundancy) public class Stars { public static void main(String[] args) { line(13, "Joe"); System.out.println(); line(7, "*"); System.out.println(); line(35, "&"); System.out.println(); int width = 50; box(10, width); System.out.println(); box(5, 5); } // prints times copies of chars on a single line public static void repeat(int times, String chars) { for(int i = 1; i <= times; i++) { System.out.print(chars); } } // prints times copies of chars then goes to the next line public static void line(int width, String chars) { repeat(width, chars); System.out.println(); } // prints a rectangle of asterisks of size width x height public static void box(int width, int height) { line(width, "*"); for(int i = 1; i <= height - 2; i++) { System.out.print("*"); repeat(width - 2, " "); System.out.println("*"); } line(width, "*"); } }