Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a header file named Triangle.h, and create the class Triangle that contains: A public double array field for the sides (or three double fields).

In a header file named Triangle.h, and create the class Triangle that contains: A public double array field for the sides (or three double fields). A public static constant double field named TORAD that is assigned 0.01745329. A public static constant double field named TODEG that is assigned 57.2957795. A public default constructor that sets the fields to 1. A public overloaded constructor that takes three (3) double parameters which should be assigned to the sides of the triangle if they are greater than 0. For any parameter that fails the condition, assign 1 to the side that is associated with the parameter. A public destructor. A public copy constructor. A public overloaded assignment operator. A public double method named Perimeter() that takes no parameters. It should return the perimeter of the triangle. A public double method named Area() that takes no parameters. It should return the area of the triangle. A public string method named ToString() that takes no parameters. It should return a string that lists the fields separated by a space. Implementing the Class Define a string function named Stats() that takes a Triangle reference as a parameter. It should return a string that lists the properties of the Triangle parameter which are its sides lengths, perimeter and area. The main function should create three Triangle objects that are assigned random sides; and then, it should call Stats() for each object. Extra Credit Within the cpp file Define a void function named Sort() that takes a Triangle reference as a parameter. It should sort the fields of the Triangle parameter in ascending order. Modify Stats() to the call Sort() before generating the string output. Extra Credit Within the cpp file Define a double function named LargestAngle() that takes Triangle reference as a parameter. It should return the largest angle of the Triangle parameter. Define a double function named MedianAngle() that takes Triangle reference as a parameter. It should return the median angle of the Triangle parameter. Define a double function named SmallestAngle() that takes Triangle reference as a parameter. It should return the smallest angle of the Triangle parameter. Modify Stats() to include the largest, median, and smallest angles in the generated string.

IN C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions