Question: Language: C++. Print Triangle with User Input, Should be Inherited From a New Classs Function: 1) In our new class called TriangleClass, we should create

Language: C++. Print Triangle with User Input, Should be Inherited From a New Classs Function:

1) In our new class called TriangleClass, we should create a function that accepts an integer from the user in order to create a triangle.

a. We should use input validation that doesnt allow the user to input anything other than an odd number.

b. The user will input the BASE of the triangle, the function will then calculate the HEIGHT. HEIGHT = ceil(BASE / 2);

c. You will need certain variables in order to do this:

i. the BASE of the triangle

ii. the HEIGHT of the triangle

iii. the MIDDLE, LOWER, and UPPER bound of the array (middle = BASE /2;)

iv. an array of characters that is dynamically allocated memory(char *stars = new char[BASE];)

d. Create a for-loop that assigns stars to elements in the array, starting from the middle point, and moving outwards after each iteration (or row)

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!