Difference between revisions of "Pythagoras"
Line 15: | Line 15: | ||
Sample Output: 3.5355339059327378 | Sample Output: 3.5355339059327378 | ||
− | |SideSection= | + | |SideSection=Primitive Data Types |
[[Image:Wiki_chars03.jpg|center]] | [[Image:Wiki_chars03.jpg|center]] | ||
<BR> | <BR> |
Revision as of 12:36, 6 April 2010
Back to the Program-A-Day homepage
ProblemCreate a program that will allow the user to enter in the lengths of two sides of a right-angled triangle, and will output the length of the triangle's hypotenuse. The two sides should be entered using two consecutive JOptionPane.showInputDialog boxes, and the result should be given using System.out.println. The input should be taken as two positive decimal values. Assume valid inputs. The formula for calculating the hypotenuse is <math>a^2 + b^2 = c^2</math>, where a and b are the two sides, and c is the hypotenuse. To solve this problem, you will need to understand:
Sample Input: 3,4 Sample Output: 5.0 Sample Input: 2.5,2.5 Sample Output: 3.5355339059327378 |
SideSectionTitlePrimitive Data Types
| |
---|---|---|
SolutionThe solution... For the entire code solution, see below. | ||
Code |