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...

The query engine is the component of the architecture that optimizes and manages queries and SQL statements.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What does the monthly customer distribution tell Chloe? How can she use this for strategic decision making?

What will be an ideal response?

Computer Science & Information Technology

________ listening includes both listening and responding to show understanding

Fill in the blank(s) with correct word

Computer Science & Information Technology

In a fiber-based LAN, an ____, fiber optic power meter, and even a fusion splicer may be needed to reconnect damaged fibers.

A. Originating Time Domain Reflectometer B. Optical Time Diffraction Reflector C. Optical Time Domain Reflectometer D. Optical Time Distortion Repeater

Computer Science & Information Technology