Question: 2) Write a program that calculates the hypotenuse of a right triangle using Pythagorean Theorem. The program should ask the user to enter 2 va
2) Write a program that calculates the hypotenuse of a right triangle using Pythagorean Theorem. The program should ask the user to enter 2 va lues. The first value is the lengt of the first triangle side, and the second value is the length of the second triangle side. Assume the values to be double. Your program should contain three methods: calculateHypotenuse, addSquares, and main. The first method (calculateHypotenuse) should use addSquares method. addSquares will first check the validity of the input (remember the sides of a triangle cannot be negative!), and if the input is valid then it will add the squares of the twos and return the result. Otherwise, it will return -1. The method calculate Hypotenuse then do the rest of the calculation to get the length of the Hypotenuse. Otherwise it return -1. h: Hypotenuse a: side 1 of right triangle b: side 2 of right triangle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
