Download The arithmetic mean of two numbers x and y is defined to be (x + y

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
The arithmetic mean of two numbers x and y is defined to be (x + y) / 2.0. The
geometric mean of the same two numbers is defined to be square root of the product x
* y.
Write a program that generates two random numbers [range 1 – 100] and prints out
both numbers, the arithmetic mean of the two numbers, and the geometric mean of the
two numbers.
The outputs should be labeled as, for example, "First number", "Second
number", "Arithmetic mean", and "Geometric mean". Note that you will have
to use variables of type double for all the numbers in this program and you may need to
check out the Math class in Java:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html
Challenge – format the output of the floating point values so that only 2 places after the
decimal are displayed (see sample output below). Hint, in Java the answer can be found
in the String class.
Professor Gray – CS114