Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago