Problem

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

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 Intermediate16 Project and save it in the Cpp7\Chap15 folder. Create a Triangle class. Enter the class definition in a header file named Intermediate16 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 Intermediate16.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

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 15