Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

GeometricMean A home purchased for 300,000 dollars increases in value by 10% after one year and by another 20% after a second year. Thus, a

GeometricMean A home purchased for 300,000 dollars increases in value by 10% after one year and by another 20% after a second year. Thus, a year after purchasing the house, its value is 1.10 300,000 dollars and after two years 1.20 1.10 300,000 dollars. A third year decrease of 6% drops the value to 94% of the previous value. 0.94 1.20 1.10 300000 372240 dollars. Notice that the multiplier is 1 0.06 0.94. The average annual increase over the three-year period is the geometric mean of 1.10, 1.20 and 0.94.

In general, the geometric mean of n numbers is the nth root of their product. Thus, the geometric mean of 1.10, 1.20, and .94 is (1.10 1.20 .94)1/3 1.074568 and the product 1.074568 1.074568 1.074568 300000 equals 372240, as does the original product, .94 1.20 1.10 300000. In other words, the homes value after three annual changes of 10%, 20%, and 6% is the same as if, each year, the homes value increased by 7.4568%.

Write a program that calculates the average increase or decrease on an investment held from one to six years. Your program should rst prompt for the length of time of the investment (an integer between 1 and 6, inclusive) and then the percent increase or decrease for each year. A negative number indicates a decrease. The program should display the average annual increase or decrease. For example, if a home, over a six-year period, has changed in value by 10%, 20%, 6%, 8%, 12%, and 3%, then to compute the average annual increase (or decrease), you would calculate the geometric mean of 1.1, 1.2, 1.06, 0.92, 0.88, and 1.03.

Hints: Overload a method, geometricMean(...). Make ve versions that have two, three, four, ve, and six parameters of type double. Use Math.pow(x,y).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions