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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started