



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Out: 3/ Due: 3/20 by 11:50 PM
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 val- ues of their angles. The study of triangles is sometimes known as triangle geometry, and is of interest to mathematicians and artists interested in gen- erating oblique shapes composed of triangles. They usually give beautiful results and unexpected properties. August Leopold Crelle, a nineteenth cen- tury German mathematician, once remarked, ”It is indeed wonderful that so simple 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, triple.in. If these num- 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, its area and perimeter, and classify the triangle according to the definitions:
Be sure to use this include directive ( #include < cmath > ) in order to use stand math library functions such as pow and sqrt. Format all output of real 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: P erimeter = A + B + C Area =
S(S − A)(S − B)(S − C), where S = P erimeter 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:
/* determines whether three numbers satisfies the triangle
/* determines whether a triangle is a right-triangle
the triple could represent the sides of a triangle. If so, your program should calculate and display the area and perimeter of the triangle and then classify the triangle, indicating whether it is a right triangle, an isosceles triangle, an equilateral triangle and a scalene triangle. On the other hand, if the triple does not satisfy the triangle inequality, your program should print a message indicating so. Once the data from triple.in have been processed, be sure to close the file.
For a sample input file, triple.in, with the data below:
7.5 4.5 6 1.0 2.0 5. 4.1 4.1 5.
A typical program interaction would be:
Enter the name of the data file> triple.in Triangle Program Report ================================= The sides of the triangle are: A = 7.50; B = 4.50; C = 6. Perimeter = 18. Area = 13. Classification: Right: Y Isosceles: N Scalene: Y Equilateral: N
The sides of the triangle are: A = 4.10; B = 4.10; C = 5. Perimeter = 13. Area = 8. Classification: Right: N Isosceles: Y Scalene: N Equilateral: N
Follow the coding style guidelines, as discussed in class, to properly doc- ument each subfunction used in this program. Include function definitions in the appropriate locations, as discussed in class. Be sure to use descriptive names for all identifiers you define in your program. Name your source file triangle.cpp. Your source file must have the following header comments:
/** @file filename @author your name @date 9999-99- Description: describe what the program does. Course: CS1253 Section: x Logon ID: cs1253xx Programming Project #: 4 Instructor: Duncan */