Starting from:
$29.99

$23.99

Homework # 3 Solution

In this homework, you will write your first C++ class. Your class name will be Triangle. This class can represent a triangle on a 2D plane with sides of length A, B, C such as T =(A=3.0, B=4.0, C=5.0)

 

 

 

Your class will have the following features

•     A no parameter constructor (A, B, C are all 1.0)

•     A one parameter constructor that will set all triangle sides to the given value.

•     A two parameter constructor that will set A and B sides and set the C side to 1.0

•     A three parameter constructor

•     Setter and getters for the required data members.

•     Input and Output functions for the triangle sides.

•     Three functions that return the angle of a triangle corner (angleA, angleB, angleC)

•    A function that returns true if the triangle is a right angle triangle

•     A function that returns the area of the triangle

•     A function that returns the perimeter of the triangle

 

You will apply all object oriented rules we learned during the lectures (member initializer syntax, const keywords, etc.)

 

Test each function of your new class at least two times with different parameters. You should also write two functions that will take Triangle objects using call by value and call by reference.

 

Notes:

•     Do not use any functions from the standard C library (like printf)

•     Do not forget to indent your code and provide comments.

•    You should always check if the triangle is valid, if not then print out an error message (cerr)

and exit the program

More products