Question: In this JAVA project, you will be creating a program to determine information about a triangle given the measurements of the sides from the user.
In this JAVA project, you will be creating a program to determine information about a triangle given the measurements of the sides from the user. Your class must be called TestTriangle To begin, use 3 JOptionPanes to obtain the measurement of 3 sides of a triangle.
Next, you will be creating the following methods to assist in determining information about the triangle entered. These methods will be called from within your main method.
isRight() - Returns true if the triangle is a right triangle and false if it is not. Use the Pythagorean Theorem to determine if it is a right triangle. Remember, you are not sure which side is the hypotenuse, so you must test all possible cases here.
isScalene() - No two sides are the same length. Use the appropriate tests to determine if the triangle is a scalene triangle or not. Returns true or false.
isIsosceles() - Exactly two sides are the same length. Use the appropriate tests to determine if the triangle is an isosceles triangle or not. Returns true or false
isEquilateral() - All three sides are the same length. Use the appropriate tests to determine if the triangle is a scalene triangle or not. Returns true or false.
findArea() -
Finds the area of the triangle. Returns a double. To compute the area, the formula is as follows... Area = (x * (x-side1) * (x-side2) * (x-side3)) ! Note the square root symbol x is computed by (1 / 2) * (side1 + side2 + side3)
"int x = (side1 + side2 + side3) / 2; double area = Math.sqrt(x * (x - side1) * (x - side2) * (x - side3));"
Note that all of the methods, with the exception of the findArea() method, return Boolean values. Determine the triangle type of the entered sides within the main method of your program by sending the inputed sides to the other methods and testing the value returned. All triangles will fall under one of the three types tested. Only print the correct type. You must also print the values of the 3 sides entered as well as the area of the triangle as found by the findArea() method. Use a JOptionPane.showMessageDialog() for your output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
