Question: Question: In this assignment, you are asked to write the definition for a triangle class and test it with the test program provided. The description
Question: In this assignment, you are asked to write the definition for a triangle class and test it with the test program provided. The description of the rectangle class and the driver program are given on the attached file triangle.cpp. Download triangle.cpp and without removing or changing any of the member functions or member variables of this class, complete 9 member function bodies such that your program produces exact output as provided. You should keep the class definition and the main function in the same source file, and you are not allowed to use global variables. Do not add any new member functions. Member Functions: triangle(int base, int hypotenuse); sets base a and hypotenuse c triangle0; initializes base to 3 and hypotenuse to 5 void setBas void setHypotenuse(int newHypotenuse); lets user change hypotenuse to a different number int getBase0 const; returns base a int getHypotenuse) const; returns hypotenuse c void printTriangle0; prints the lengths of each side of the triangle a, b, and c double getArea0; returns the area of the triangle double getPerimeter0; returns the perimeter of the triangle e(int newBase); lets user change base to a different number HINT: to find the height of the triangle, you must solve the Pythagorean theorem for b b sqrt(pow(c, 2)- pow(a, 2))] Area: R 1/2 a b Perimeter: Pa+b+c Pythagorean Theorem: a 2+ b2c2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
