// Zorah Fung, CSE 142 // This program prints out several lines of stars of various lengths // and several boxes of stars of various widths and heights // Note: We can parameterize this code more (shown in StarsFinalVersion.java) to // generalize our code and enhance readi bility but this version is still perfectly acceptable! public class StarsVersion2 { public static void main(String[] args) { printLine(13); printLine(7); printLine(35); printBox(10, 5); printBox(5, 6); } // Prints out a line of stars of the given length public static void printLine(int numberOfStars) { for (int i = 1; i <= numberOfStars; i++) { System.out.print("*"); } System.out.println(); } // Prints out a hollow box of stars of the given width and height public static void printBox(int width, int height) { printLine(width); 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("*"); } printLine(width); } }