Write a short program that allows the user to enter the base and height of a triangle and outputs the hypotenuse, formatted to three decimal places.

What will be an ideal response?

```
import java.util.Scanner;
import java.text.DecimalFormat;
public class Hypotenuse {
public static void main(String [] args) {
double base, height, hypotenuse;
Scanner input = new Scanner(System.in);
DecimalFormat fmt = new DecimalFormat("0.###");
System.out.print("Please enter the base: ");
base = input.nextDouble();
System.out.print("Please enter the height: ");
height = input.nextDouble();
hypotenuse = Math.sqrt(Math.pow(base,2) + Math.pow(height,2));
System.out.println("The hypotenuse is " + fmt.format(hypotenuse)

+ ".");

}//end main
}//end class
```

Computer Science & Information Technology

You might also like to view...

A(n) ________ fill blends two or more colors

Fill in the blank(s) with correct word

Computer Science & Information Technology

On the Replace tab of the Find and Replace dialog box, the ____________________ expressions option allows you to use search terms to find patterns rather than just exact matches.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology