Question: Write a console program to: 1. Read an input file that contains sets of 3 numbers separated by the delimiter (#) until the end of
Write a console program to:
1. Read an input file that contains sets of 3 numbers separated by the delimiter (#) until the end of file. Check that the file was successfully opened.
2. All program output should be written to the output file Output.txt
3. For each set of 3 numbers, determine if the 3 values can form the sides of a triangle. (The sum of the lengths of any two sides of a triangle must be greater than the length of the third side. For Example, the numbers 3, 4, and 5 can form a triangle because 3+4 > 5, 4+5 > 3, and 5+3 > 4. In contrast, the numbers 1, 2, and 5 cannot form a triangle because 1+2 < 5. Thus, if you are given any three integers, you can determine whether they could possibly form a triangle or not by applying this general principle.)
4. If the values cannot form a triangle, display the appropriate message in the output file. For those sets of numbers that can form a triangle, display the type of triangle and the perimeter of the triangle. (Use the triangle class described below to determine the type and perimeter, but create the output in the main method.) Example: The values 3, 4 and 5 form a right triangle with perimeter = 12. The values 1, 1, and 10 cannot form a triangle.
5. Create a Triangle class that contains a constructor and 4 methods. The constructor must set the values of the sides of the triangles. There should be a method to do each of the following:
a. Calculate and return the perimeter of the triangle
b. Determine if the triangle is a right triangle (a2 + b2 = c2, where c is the hypotenuse - the largest side), Return True if it is, and False if it is not.
c. Determine if the triangle is an equilateral triangle (all 3 sides are equal). Return True, if it is and False if it is not.
d. Determine if the triangle is an isosceles triangle (only 2 sides are equal). Return True, if it is and False if it is not
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
