Lab 8: Post-Lab Assignment

Due before class on Friday November 5th

Write a program to print a diamond-shaped pattern of stars (asterisks). Your program should ask the user to enter the number of rows in the top part of the diamond, then print the diamond (which will consist of a triangle with the number of rows specified with a second "upside down" triangle with one less row). For example, if the user enters 6 for the number of rows the program should print:
            *
           * *
          * * *
         * * * *
        * * * * *
       * * * * * *
        * * * * *
         * * * *
          * * *
           * *
            *
HINTS: You will need several nested for loops similar to the nested loop in the Stars program on page 148 of the text. Note that in the above diamond there is a blank space inbetween each star. You will need to make adjustments to the loop control and other parts of the header in the for loop to get the right number of stars printed. Also note that you need to print some blank spaces before each row to "move" the stars over. Printing blank spaces is just like printing the asterisks - you need a loop. It would be a good idea to get the top half right then add the bottom part of the diamond.

Requirements: As usual you must use good programming style and document your program (including header documentation that describes what the program does and includes your name, documentation on the main method, and in-line documentation to mark the main sections of code). Your program should be in the lab8 package created in lab.
Submission

From your postlab8 directory, tar your code using the command:

   tar czf username.tgz ClassName.java
Where username is the name you use to log into the lab machines and ClassName is the name of the file that contains your java code.

To submit your code, copy the tar file containing your code to the directory:

   ~bouchard/cpsc120/post8