Question: By following the steps below using the test editor file from the Topic 1 assignment and a new input.txt file that will be created below,
By following the steps below using the test editor file from the Topic 1 assignment and a new "input.txt" file that will be created below, you will develop a program that reads three numbers on a line from the text file and interprets them as the length of three sides of a triangle. The program then examines the lengths of the lines and prints out:
- "Equilateral" if the three lines are of equal (positive) length.
- "Isosceles" if the two of the three lines are of equal (positive) length and the remaining
line is of different (positive) length that is shorter than the sum of the other two lines.
- "Scalene" for any other valid triangle.
- "Not a Triangle because
" otherwise.
The program loops to read each line of input and processes it in turn. Use exception handling to trap input errors, and report them as "Not a Triangle because: <>".
- Example Use Case: Create the "input.txt" file to contain the 3 lines below. Note that
the final file will contain many more than 3 lines.
1 1 1
2 2 1
2 x 3
- Expected output:
Equilateral
Isosceles
Not a Triangle because: second line is not a number.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
