Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROBLEM 2: Drawing shapes use the printLine function created in class to write a

ID: 3646575 • Letter: P

Question

PROBLEM 2: Drawing shapes
use the printLine function created in class to write a menu driven program that generates 6 different shapes (note that Diamond is extra credit). For a size of 5, here are the shapes:

Triangle1 Triangle2 Triangle3 Triangle4
* ***** * *****
** **** ** ****
*** *** *** ***
**** ** **** **
***** * ***** *

DiagonalUp DiagonalDown
* *
* *
* *
* *
* *

To simplify your code, create a function for each shape which calls printStars to do the drawing. So you should have 6 functions plus printLine. You could also create a function to print the menu if you want. Sample output:


Shapes Menu
1: Triangle 1
2: Triangle 2
3: Triangle 3
4: Triangle 4
5: Diagonal Up
6: Diagonal Down
7: Quit
Enter choice: 2
Enter size: 3

***
**
*
Shapes Menu
(print menu)
Enter choice: 6
Enter size: 4

*
*
*
*
Shapes Menu
(print menu)
Enter choice: 7
Goodbye
Press any key to continue . . .

Explanation / Answer

//I have written same in Java. Try to convert it into C++ using equivalent functions //shape and size as first and second argument through command line arguments class draws { public void triangle1(int p) { for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote