Solutions to warmups
public class Main { public static void main(String[] args) { printAlphabet(); cross(5); } public static void printAlphabet() { final int LETTERS_IN_ALPHABET = 26; for (int i = 0; i < LETTERS_IN_ALPHABET; i++) { System.out.print((char) (i + 'a')); } } // Domain: a character and the number of times the character // should be printed public static void printChars(char c, int n) { for (int i = 0; i < n; i++) { System.out.print(c); } } public static void cross(int n) { // First n lines: n spaces followed by n asterisks // Middle n lines: 3n asterisks // Last n lines: n spaces followed by n asterisks // First n lines for (int i = 0; i < n; i++) { printChars(' ', n); printChars('#', n); System.out.println(); // Move to a new line } // Middle n lines for (int i = 0; i < n; i++) { printChars('#', 3 * n); System.out.println(); // Move to a new line } // Last n lines for (int i = 0; i < n; i++) { printChars(' ', n); printChars('#', n); System.out.println(); // Move to a new line } } public static String starString(int n) { String str = ""; for (int i = 0; i < n; i++) { str = str + "*"; } return str; } public static void drawSquare(int n) { for (int i = 0; i < n; i++) { System.out.println(starString(n)); } } } }