Question: Write a program in C++ that will randomly choose colors, and depending on the options chosen, randomly choose shapes. Constraints: Prompt the user for the

Write a program in C++ that will randomly choose colors, and depending on the options chosen, randomly choose shapes.

Constraints:

Prompt the user for the size of the image. The image itself will be a square. So use this value for the height and width in the svg start tag.

Prompt the user for the number of shapes per row/column. This is the number of columns and rows in the image. For example, if the user entered 4, then there would be 4 rows and 4 columns.

Prompt the user for the background color. There are only 5 background colors allowed: red, green, blue, white, and black.

Ask the user what shapes to generate. Use these options:

 1-rect 2-circle 3-up triangle 4-down triangle 5-all 6-all w/blanks 

These dictate the rules for which shapes are drawn in the images.

When the user selects 1, all the shapes in the image will be squares

When 2, all the shapes will be circles

When 3, all the shapes will be triangles with the point on the "top"

When 4, all the shapes will be triangles with the point on the "bottom"

When 5, randomly choose among the 4 shapes. Each shape has an even chance of being chosen.

When 6, randomly choose among the 4 shapes and the possibility of a blank spot. Each shape and the blank spot has an even chance of being chosen.

When outputting shapes, All the colors should be randomly generated. For options options 5 and 6, use random values to choose the shapes to output.

Use the input values to generate the file art.svg using ofstream and the required functions defined below.

You cannot include cmath.

initialize the random number generator with

 srand(time(NULL)); 

Required Functions

- generate SVG() - background() - rect() -circle() -triangle() -fill()

Sample Run

Enter the image size: 400 Enter the number of shapes per row/column: 4 Enter background color: white Enter the shape to use 1-square 2-circle 3-up triangle 4-down triangle 5-all 6-all w/blank 
 Choice: 1 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!