• • • • • • • A triangle is a three-sided polygon. Every triangle has three side
ID: 3617743 • Letter: #
Question
•
•
•
•
•
•
•
A triangle is a three-sided polygon. Every triangle has three sides and three
angles, some of which may be the same. Every triangle satisfies the so-called
triangle inequality: the sum of any two sides must be greater than the third
side. Triangles can be classified by the length of their sides or the values of
their angles. The study of triangles is sometimes known as triangle geome-
try, and is of interest to mathematicians and artists interested in generating
oblique shapes composed of triangles. They usually give beautiful results
and unexpected properties. August Leopold Crelle, a nineteenth century
German mathematician, once remarked, ”It is indeed wonderful that so sim-
ple a figure as the triangle is so inexhaustible in properties. How many as
yet unknown properties of other figures may there not be?”
Your program will a set of triples from a text file,
bers cannot form the sides of a triangle, your program will print a message
indicating so. If these numbers can represent the lengths of the sides of a
triangle, your program will print a report showing the sides of the triangle,
1. An
2. A triangle with all sides equal is called an
3. A triangle with no two sides equal is called a
4. A
equation
Be sure to use this include directive ( #include
stand math library functions such as
numbers to 1 decimal place. Assume that all input values are positive.
Relevant Formulas:
Let A, B and C denote the sides of the triangle:
Perimeter
Area
2
A modular implementation must be designed using functions. In addition
to the main function, your program will consist of the following user-defined
functions; you may design more:
1. bool isTriangle(double num1, double num2, double num3)
1. num1 a real number
2. num2 a real number
3. num3 a real number
return true if the sum of pair of these numbers is greater
than the third; otherwise, false is returned. Also returns
false if any of the numbers is non-positive.
2. bool isRight(double sideA, double sideB, double sideC)
1. sideA the length of a side
2. sideB the length of a side
3. sideC the length of a side
return true if the sum of squares of the lengths of two sides
is equal to the third side; otherwise, false is returned.
3. bool isEquilateral(double sideA, double sideB, double sideC)
1. sideA the length of a side
2. sideB the length of a side
3. sideC the length of a side
return true if the sides are equal; otherwise,
4. bool isIsosceles(double sideA, double sideB, double sideC)
1. sideA the length of a side
2. sideB the length of a side
3. sideC the length of a side
return true if at least two sides are equal; otherwise,
false is returned.
5. bool isScalene(double sideA, double sideB, double sideC)
1. sideA the length of a side
2. sideB the length of a side
3. sideC the length of a side
return true if no two sides have the same lengths; otherwise,
false is returned.
6. void calcTriangle(double sideA, double sideB, double sideC,
double& perimeter, double& area)
1. sideA the length of a side
2. sideB the length of a side
3. sideC the length of a side
4. perimeter the perimeter of the triangle
5. area the area of the triangle using Herron’s formula.
Your program should ope
Explanation / Answer
please rate - thanks #include #include #include using namespace std; bool istriangle(double,double,double); void calcTriangle(double, double, double ,double& , double&); bool isRight(double , double , double ); bool isEquilateral(double , double , double ); bool isIsosceles(double , double , double ); bool isScalene(double , double , double ); int main() {double a,b,c,area,perimeter; ifstream input; input.open("triple.in"); //open file if(input.fail()) //is it ok? { coutb>>c; if(istriangle(a,b,c)) {coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.