Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

3. Develop a case study.

Answered: 1 week ago