/*
 * Diamond.java
 *
 * This program uses for loops to draw a diamond.
 *
 * Here are the table of values for the up-facing triangle:
 *
 * | line | spaces | asterisks |
 * | 1    | 4      | 1         |
 * | 2    | 3      | 3         |
 * | 3    | 2      | 5         |
 * | 4    | 1      | 7         |
 * | 5    | 0      | 9         |
 *
 * Here, spaces(line) = 5 - line and
 * asterisks(line) = 2 * line - 1.
 *
 * For the down-facing triangle:
 *
 * | line | spaces | asterisks |
 * | 1    | 1      | 7         |
 * | 2    | 2      | 5         |
 * | 3    | 3      | 3         |
 * | 4    | 4      | 1         |
 *
 * Here, spaces(line) = line and
 * asterisks(line) = 9 - 2 * line.
 *
 * Author: S-111 Course Staff
 * Date: June 26, 2015
 */

public class Diamond {
    public static void main(String[] args) {

        // draw the up-facing triangle
        for (int line = 1; line <= 5; line++) {
            // draw the spaces
            for (int i = 0; i < 5 - line; i++) {
                System.out.print(" ");
            }

            // draw the asterisks
            for (int i = 0; i < 2 * line - 1; i++) {
                System.out.print("*");
            }

            System.out.println();
        }

        // draw the down-facing triangle
        for (int line = 1; line <= 4; line++) {
            // draw the spaces
            for (int i = 0; i < line; i++) {
                System.out.print(" ");
            }

            // draw the asterisks
            for (int i = 0; i < 9 - 2 * line; i++) {
                System.out.print("*");
            }

            System.out.println();
        }
    }
}
