handout #7

CSE142—Computer Programming I

Programming Assignment #2

due: Monday, 10/11/04, 9 pm

This assignment will give you practice with for loops, static methods, print/println statements and a program constant.  This is assignment is worth 15 points instead of the normal 20 points.  You are going to generate output that looks like the following:

     /**\

    //**\\

   ///**\\\

  ////**\\\\

 /////**\\\\\

+=*=*=*=*=*=*+

|../\..../\..|

|./\/\../\/\.|

|/\/\/\/\/\/\|

|\/\/\/\/\/\/|

|.\/\/..\/\/.|

|..\/....\/..|

+=*=*=*=*=*=*+

|\/\/\/\/\/\/|

|.\/\/..\/\/.|

|..\/....\/..|

|../\..../\..|

|./\/\../\/\.|

|/\/\/\/\/\/\|

+=*=*=*=*=*=*+

     /**\

    //**\\

   ///**\\\

  ////**\\\\

 /////**\\\\\

The various subfigures in the middle of this output have a height of 3.  These subfigures have the property that their height determines their width, so there is only one size variable.  You are going to use a program constant to make it possible to change a single number in one place in the program to have it produce a corresponding figure of a different size.

You are to use the constructs from chapters 1 and 2  and only those constructs to accomplish this task.  This will require you to create nested for loops with print and println statements that use the program constant.  Do not use value parameters or other advanced features of Java to complete this task.  Those advanced features can lead to a better program, but we want to make sure that everyone is solving the same problem using the same tools.

You should continue to use static methods to structure your solution.  You should try to avoid significant redundancy and you should structure your program in such a way that the methods match the structure of the output itself.  You should localize variables whenever.possible.

Include a comment at the beginning of your program with basic information and a description of the program and include a comment for each method.  Name your file DrawRocket.java and turn in your program electronically through the “assignments” link on the class web page.

On any given execution your program will produce just one version of this figure, but it should be possible to change the value of the program constant to have your program produce a figure of a different size.  For example, with subfigures of height 7, the figure should look like this:

             /**\

            //**\\

           ///**\\\

          ////**\\\\

         /////**\\\\\

        //////**\\\\\\

       ///////**\\\\\\\

      ////////**\\\\\\\\

     /////////**\\\\\\\\\

    //////////**\\\\\\\\\\

   ///////////**\\\\\\\\\\\

  ////////////**\\\\\\\\\\\\

 /////////////**\\\\\\\\\\\\\

+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+

|....../\............/\......|

|...../\/\........../\/\.....|

|..../\/\/\......../\/\/\....|

|.../\/\/\/\....../\/\/\/\...|

|../\/\/\/\/\..../\/\/\/\/\..|

|./\/\/\/\/\/\../\/\/\/\/\/\.|

|/\/\/\/\/\/\/\/\/\/\/\/\/\/\|

|\/\/\/\/\/\/\/\/\/\/\/\/\/\/|

|.\/\/\/\/\/\/..\/\/\/\/\/\/.|

|..\/\/\/\/\/....\/\/\/\/\/..|

|...\/\/\/\/......\/\/\/\/...|

|....\/\/\/........\/\/\/....|

|.....\/\/..........\/\/.....|

|......\/............\/......|

+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+

|\/\/\/\/\/\/\/\/\/\/\/\/\/\/|

|.\/\/\/\/\/\/..\/\/\/\/\/\/.|

|..\/\/\/\/\/....\/\/\/\/\/..|

|...\/\/\/\/......\/\/\/\/...|

|....\/\/\/........\/\/\/....|

|.....\/\/..........\/\/.....|

|......\/............\/......|

|....../\............/\......|

|...../\/\........../\/\.....|

|..../\/\/\......../\/\/\....|

|.../\/\/\/\....../\/\/\/\...|

|../\/\/\/\/\..../\/\/\/\/\..|

|./\/\/\/\/\/\../\/\/\/\/\/\.|

|/\/\/\/\/\/\/\/\/\/\/\/\/\/\|

+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+

             /**\

            //**\\

           ///**\\\

          ////**\\\\

         /////**\\\\\

        //////**\\\\\\

       ///////**\\\\\\\

      ////////**\\\\\\\\

     /////////**\\\\\\\\\

    //////////**\\\\\\\\\\

   ///////////**\\\\\\\\\\\

  ////////////**\\\\\\\\\\\\

 /////////////**\\\\\\\\\\\\\