Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement a class to compute the area of a triangle using the values of their sides. The design of class (named Triangle)

Design and implement a class to compute the area of a triangle using the values of their sides. The design of

Design and implement a class to compute the area of a triangle using the values of their sides. The design of class (named Triangle) should include: 1) Three private members sidel, side2, and side3, which present sides of a triangle. 2) One private member area to preserve the computed area of triangle. 3) A default constructor (i.e., Triangle()) to initialize sides of triangle and area of triangle as zero. 4) A parameter constructor (i.e., Triangle (double, double, double)) to initialize the values of sides for corresponding triangle and initialize area of triangle as zero. 5) A set method (i.e. setSides (double, double, double)) to enter the new values for the sides. 6) A method (i.e. computeArea()) to compute the area of triangle. 7) A get method (i.e. getArea()) to display the area. Hint-1. Area of Triangle can be computed through the following Heron's Formula: Area = sqrt(s* (s-a)*(s-b)*(s-c)), where s=(a+b+c)/2. Hint-2. You need to include library to use the sqrt() function and include library to use setprecision and fixed manipulators to change the precision value and printing format. According to the requirements above, write a program to: 1) Create first Triangle object (i.e., triangLe1) with default constructor and display its area. 2) Create second Triangle object (i.e., triangle2) with parameter constructor and display its area. The values of sides are 3, 4, and 5. 3) Call the set method using first Triangle object (i.e., triangle1) and display its area. Assume that all inputs are valid, i.e., new sides can form a triangle. Expected Outputs: Example 1. Area of triangle1: 0.00 Area of triangle2: 6.00 Enter new sides for triangle1: 423 Area of triangle1: 2.90 Example 2. Area of triangle1: 0.00 Area of triangle2: 6.00 Enter new sides for triangle1: 3 3 3 Area of triangle1: 3.90

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Certainly Below is the C program implementing the described Triangle class with the specified featur... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Computer Network questions

Question

1. Arouse curiosity with questions such as What would happen if?

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago