starting foreach
Practice with:
Write a program, AreaTriangle
, that prompts the user three times for the side
lengths of a triangle. Based on these three inputs, the program checks and prints whether this triangle is isosceles or not, as well as its area.
In addition to the main()
method, your program should also define three
other static methods :
isValidTriangle()
to check whether the three inputs define a triangle, based on the triangular inequality (that is, the sum of any two sides of a triangle is strictly greater than the third side),getHeronArea()
compute the triangle's area based on Heron's Formula given the three side lengths,isIsosceles()
to check whether the triangle is isoscelesSome important notes on this exercise:
System.exit(1)
for that. Some sample executions of this program are shown below:
Think carefully about the set of inputs (testing cases) you will provide to your program to assert its correctness. Your inputs should be such that every method you wrote is tested (invoked) as your program runs.
Make sure you give reasonable and useful names to your methods, and that you write meaningful comments in your program.
In BlueJ, save the results of your testing produced in the "BlueJ: Terminal Window" into a file called AreaTriangleTest.txt. (Options > Save to File...)
It is a standard policy of this course that submissions that have not been signed (@author
) and dated (@version
) will not be graded.
Your Gradescope submission should contain the following:
AreaTriangle.java
fileAreaTriangleTest.txt
file that contains your testing results