I have to do a program that consists of the following requirements. From what I can gather i have to create a program that calculates the area of three edges, produced from a separate text file, of a triangle but produces the results in another text file:
The area of an arbitrary triangle can be computed using the formula:
area = √s(s - a)(s-b)(s-c)
where a, b, and c are the lengths of the sides, and s is the semiperimeter.
s = (a+b+c)/2
the information supplied in the edges.txt file is:
12 15 7
8 9 14
11 2 15
6 5 4
18 7 10
16 11 17
However, not all three integers a, b, and c will produce a triangle. This is because for any triangle the sum of the lengths of any two edges shall be greater than the length of the remaining edge.
In this assignment, the lengths of edges are grouped and stored in a file named “edges.txt”. Each line of the file contains a group of three edges, which may or may not produce a triangle as discussed above. Your program reads each group of three edges from the file and determines whether or not they produce a valid triangle. If the three edges produce a valid triangle, compute its area and store the area the file “area.txt” with the precision of 2. Otherwise, write the letter “*” in the corresponding line. Each line of the file “area.txt” contains an area or a “*” symbol.
In your program, you shall apply the procedure abstract methodology, i.e., breaking large problems into smaller sub-tasks. For example, you can define the following three functions in your program