// CSE 142, Autumn 2009, Marty Stepp // This program prints several lines and boxes of stars using parameters. public class Stars { public static void main(String[] args) { lineOfStars(13); System.out.println(); lineOfStars(7); System.out.println(); lineOfStars(35); System.out.println(); System.out.println(); boxOfStars(10, 6); boxOfStars(5, 4); // boxOfStars(95, 27); } // Prints a line of the given number of stars. public static void lineOfStars(int times) { for (int star = 1; star <= times; star++) { System.out.print("*"); } System.out.println(); } // Prints a box of stars of the given width and height. public static void boxOfStars(int width, int height) { lineOfStars(width); // top // middle 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("*"); } lineOfStars(width); // bottom } }