Question: Write a program that prompts the user to enter two positive floating- point numbers and prints their arithmetic mean, geometric mean, and harmonic mean (see
Write a program that prompts the user to enter two positive floating-
point numbers and prints their arithmetic mean, geometric mean, and harmonic mean (see
the notes below for how to calculate each of them). When the user enters 4.2 and 2.7, the
output of your program should look exactly like the following:
Enter two positive floating-point numbers: 4.2 2.7
The arithmetic mean is 3.45.
The geometric mean is 3.37.
The harmonic mean is 3.29.
Notes:
1. Make sure to properly display a floating-point number with two digits on the right of
the decimal point.
2. arithmeticMean = (number1 + number2) / 2.0;
geometricMean = Math.sqrt(number1 * number2);
harmonicMean = (2.0 * number1 * number2) / (number1 + number2);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
