Question: baseValue and heightValue are read from input. Declare and assign pointer myTriangle with a new Triangle object. Then, set myTriangle's base and height to baseValue

baseValue and heightValue are read from input. Declare and assign pointer myTriangle with a new Triangle object. Then, set myTriangle's base and height to baseValue and heightValue, respectively.

Ex: if the input is 10.0 5.5, then the output is:

Triangle's base: 10.0 Triangle's height: 5.5

#include #include using namespace std;

class Triangle { public: Triangle(); void Print();

double base; double height; }; Triangle::Triangle() { base = 0.0; height = 0.0; } void Triangle::Print() { cout << "Triangle's base: " << fixed << setprecision(1) << base << endl; cout << "Triangle's height: " << fixed << setprecision(1) << height << endl; }

int main() { double baseValue; double heightValue; /* Additional variable declarations go here */ cin >> baseValue; cin >> heightValue; /* Your code goes here */ myTriangle->Print(); return 0; }

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!