Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the source code file (in C++) EquilateralTriangle.cpp Include necessary he

ID: 3917568 • Letter: W

Question

Write the source code file (in C++)

EquilateralTriangle.cpp

Include necessary header files and implementation of each member function of the following

EquilateralTriangle class.

?

class EquilateralTriangle

{

public:

    EquilateralTriangle(double initial_length, string initial_color);

    double get_length() const;

    string get_color() const;

    double get_area() const;

private:

    double length;

    string color;

};

?

The area of an equilateral triangle is

Area

=

3

4

a

2

?a is the length of the side. Use the math.h library function sqrt( value ) to calculate square root of a number.

Explanation / Answer

#include<iostream>

using namespace std;

#include<math.h>

double get_area(s)

{

double area;

area = sqrt(3)/4*(s*s);

return area;

}

main()

{

float s1;

float eq_area;

cout << " Calculate the area of the Equilateral Triangle : "; cout << " ---------------------------------------------------- ";

cout<<" Input the value of the side of the equilateral triangle: ";

cin>>s1;

eq_area = get_area(s1);

cout<<" The area of equilateral triangle is: "<<eq_area<<endl;

cout << endl;

return 0;

}