1. Create a file called data.txt with the following data, which are the lengths of the sides of an irregular pentagon in order going clockwise (a, b, c, d, and e). The data file should only contain these five numbers.
45 105 45 90 90
2. Write a C++ program that does the following.
a. Reads the data from the file using 5 separate variable names (e.g. a, b, c, d and e).
b. Assuming the angles between sides a and b as well as b and c are 90 degrees, the program then calculates the remaining three angles of the pentagon.
c. Prints a table to the screen as neatly as possible of the sides and their included angle.
d. In the fourth column of the table, the program prints the word "greater" if the angle is greater than 90 degrees, "less" if the angle is less than 90 degrees and "equal" if the angle is equal to 90 degrees.
Note that the program must be able to run with any data file of five numbers (when a and c are equal and d and e are equal and the angles between a and b and b and c are always 90), not just this set of five. Also, always assume that the pentagon is convex (meaning it points out, not inward).
i am trying to have my equal, greater, and less statements appear under the "Size" column but i have no idea how to do so. Whats wrong with my code?
Thanks
You should not put a semicolon after an if statement, because that reads as: if the condition is true, do nothing and then (always) execute the following block.
Another odd line is:
S1; S2; Angle; Size
It doesn't have any effect. However, your compiler should warn you about this. It should also warn you that Size is never initialized.