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
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
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