Lab 3

For this week's lab, we will work with loops and random number generator to print different shapes.

Synopsis:

Asterisk Printing

Write a program in Java to generate a random number then draw Asterisk shapes based on generated random number. The asterisk shapes is described for each Point.

The number of asterisk to print must be odd. So you must write code to generate random odd numbers. And you would not like this number to be too large.

You can use the random number generator in Prog 2, or other ones.

Use the starter code at bottom of this page to begin your assignment, The starter code accepts an input and draw the following shapes as follows:

 

Generated random number of asterisk to print:

9

 

Option 1

**********

 

Option 2

 

*

**

***

****

*****

******

*******

********

*********

For 1 point: 

You add Code to draw the following shape:

 

*

**

***

****

*****

******

*******

********

*********

********

*******

******

*****

****

***

**

*

 

For 1 point 

You add Code to draw the following shape:

 

For 1 point: 

You add Code to draw the following shape:

 

Submission.

 1. You should work with a partner for a grade. Only one of you need to submit. In other words, only one submission per group.

 2. You should turn in to Blackboard within one hour after the beginning of the lab. (9am for 8am lab, 10am for 9am lab, 11am for 10am lab and noon for 11am lab) .

 3. Submission should have both partners' names and the lab time in comments at the top.

 4. Submitted file name should follow: Lab3_netid1_netid2.java

Failure to so the above will make it difficult for TAs to locate your (and your partner's) lab code. This is not good news for you.

Grading Criteria.

1 point: generate a random number and make sure it is odd. make sure the size of shape can fit the screen

1 point for each of 3 shapes, the last shape counted as extra credit