Question: In this exercise, you create a Triangle class and a program that uses the Triangle class to instantiate a Triangle object. a. If necessary, create

In this exercise, you create a Triangle class and a program that uses the Triangle class to instantiate a Triangle object. 

a. If necessary, create a new project named Intermediate17 Project and save it in the Cpp8\Chap15 folder. Create a Triangle class. Enter the class definition in a header file named Intermediate17 Triangle.h. The class should include a void method that allows the program to set the triangle’s dimensions. The method should verify that all of the dimensions are greater than 0.0 before assigning the values to the private data members. The class also should include two value-returning methods. One value-returning method should calculate the area of a triangle, and the other should calculate the perimeter of a triangle. The formula for calculating the area of a triangle is 1/2 * b * h, where b is the base and h is the height. The formula for calculating the perimeter of a triangle is a + b + c, where a, b, and c are the lengths of the sides. Determine the appropriate variables to include in the class. Be sure to include a default constructor that initializes the variables. 

b. Create a program that prompts the user for the triangle’s dimensions and then displays the triangle’s area and perimeter amounts. Enter your C++ instructions in a source file named Intermediate17.cpp. Display the amounts with zero decimal places. Also enter appropriate comments and any additional instructions required by the compiler. Save and then run the program. Test the program appropriately

Step by Step Solution

3.38 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The answer to your questions consists of 2 files Triangleh and Intermediate17cpp a Triangleh This header file contains the class Triangle with the req... View full answer

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 Microsoft Visual C# Introduction Questions!