// Improved version of the MyStars program that uses // parameters to write generalized versions of methods // to print lines and boxes. public class MyStarsGood { public static void main(String[] args) { line(5); line(12); line(9); System.out.println(); box(5, 5); System.out.println(); box(3, 7); System.out.println(); box(7, 3); System.out.println(); box(10, 5); System.out.println(); System.out.println(); } // Prints a line of asterisks of the given length. // // int length - the number of asterisks to print in the line public static void line(int length) { for (int i = 1; i <= length; i++) { System.out.print("*"); } System.out.println(); } // Prints a box of asterisks with the given width and height. // // int width - the width of the box // int height - the height of the box public static void box(int width, int height) { for (int i = 1; i <= height; i++) { for (int j = 1; j <= width; j++) { System.out.print("*"); } System.out.println(); } } }