Emmma W.

asked • 08/02/21

Please slove it In C++ .

Tasks:

Create the following classes.

1. Triangle:

a. Properties: side1, side2 and side3. Properties should be private and should be of double

datatype.

b. Functions:

i. Constructor function with parameters to assign values to the properties.

ii. Constructor function to overload default constructor (a constructor with no parameter).

Set zeros to all properties.

iii. Getter and setter functions for all properties.

iv. getArea() function that returns the area of the Triangle.

v. getPerimeter() function that returns the perimeter of the triangle.


2. Fraction:

a. Properties: numerator and denominator. Properties should be private and of int datatype.

i. Constructor function with parameters to assign values to the properties. You need to

check if the value of the denominator is set as 0 by the user. If done so, you should

change it to 1.

ii. Constructor function to overload the default constructor (a constructor with no

parameter). You should assign 0 to the numerator and 1 to the denominator.

iii. Getter and setter functions for all properties.


Finally create two objects of each class (two Triangle objects and two Fraction objects). One of the two objects

should be created using the normal constructor and the other should be created with the parameter-less

constructor. You need to do this in the driver (main.cpp) file.

1 Expert Answer

By:

Patrick B. answered • 08/02/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.