Question: Write a program that draws geometric figures using *. The program should have a menu that asks the user what picture he wants to draw:

Write a program that draws geometric figures using *. The program shouldWrite a program that draws geometric figures using *. The program should have a menu that asks the user what picture he wants to draw:

Square

Triangle

Diamond [Challenge]

After the user selects the figure to draw, the program will ask the user the size of the figure (n). The program then will call the respective function (square(n) for square, triangle(n) for triangle, diamond(n) for diamond), and draw the figure. Each one takes the value of n as parameter. Each functions outputs to screen the figure.

In the case of diamonds, the user can only input odd numbers, and this needs to be validated.

See some sample runs:

1. Square 2. Triangle 3. Diamond 0. EXit 1 The program has a menu. Choice 1, asks t value of n, calls function square with num n 5. Function square draws a square of si 1. Square 2. Triangle 3. Diamond 0. Exit The program shows the menu again. Choi asks the value of n, calls the function wit number n-6. Function triangle draws a tri of size 6 * 1. Square 2. Triangle 3. Diamond 0. Exit The program continues to run until the us inputs zero in the menu. 1. Square 2. Triangle 3. Diamond 0. Exit (odd) n = 10 I only accept odd numbers 1. Square 2. Triangle 3. Diamond 0. Ex1t If the user selects a diamond, the progran validates that the number is odd, if it is o then it draws a diamond as shown in the picture (odd) n = 7 1. Square 2. Triangle 3. Diamond 0. Exit

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!