C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Calculating Average annual and compound annual growth rates and future Reads in houseprices data from a text file and calculates average annu Rate Topic: -----

#1 ankh  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-August 06


Dream Kudos: 0

Share |

Calculating Average annual and compound annual growth rates and future

Posted 08 August 2006 - 08:13 PM

Attached File  houseprices.txt (447bytes)
Number of downloads: 124Background
A real estate company needs to study the house price movement of a given city in the past 35 years in order to advise its clients.

Task
write a C++ program that reads in the house price data from a file and then

calculate the compound annual growth rates as well as average annual growth rates of the median house prices of that city in the last 5, 10, 15, 20, 25, 30 and 35 years.

calculate the median house prices of the city in the next 5, 10, 15, and 20 years if the house prices follow the compound annual growth rate of the last 35 years.


The Input Data

The input data are stored in a text file. Each file contains at least 35 years price data. Each line of the file contains the year and the median house price of that year. The lines are ordered in years with the latest year comes first, as shown in this sample file houseprices.txt. (the whole file is attached)

2005 295000
2004 255000
2003 226000
2002 185542
2001 171800
2000 157576
1999 147879
1998 142383
1997 133241
1996 126724
1995 127931



The Average Annual Growth Rate over a number of years means the average of the annual growth rates over that number of years. For example, assume that in 2005, the price has increased over 2004 by 10%, 2004 over 2003 by 15%, and 2003 over 2002 by 5%, then the average annual growth rate from 2002 to 2005 is

(10% + 15% + 5%) / 3 = 10%

Compound Annual Growth Rate Over Years

--------------------------------------

Assume the house price has changed from an old price
to a new price over a number of year, the compound
annual growth rate of the house price over that
number of years would be:

(new price / old price ) ^ ( 1 / number of years ) - 1

For example, if in 2002, the house price was $220K
and in 2005 it became $330K then the compound annual
growth rate of house price over the three year period
from 2002 to 2005 is

( 330K / 220K )^( 1 / (2005 - 2002) ) - 1
= 1.5 ^ ( 1/3 ) - 1
= 1.145 - 1
= 0.145
= 14.5%

To calculate the power C++, you need to use the standard
function pow from <cmath>.

Calculate New Price
-------------------


If you know the old price and the compound annual growth
rate of house price, the new price after a number of years
would be

(old price) * (1 + compound annual growth rate ) ^ (number of years)

For example, assuming the house price was $220K in 2002, and the
compound annual growth rate is 14.5%, then house price in 2005
would be

(220,000) * (1 + 14.5%)^(2005-2002)
= 220,000 * (1.145 ^ 3)
= 220,000 * 1.5
= 330,000

Any help with this would be appreciated.

Much Thanks
Was This Post Helpful? 0
  • +
  • -


#2 Dark_Nexus  Icon User is offline

  • or something bad...real bad.
  • Icon

Reputation: 142
  • View blog
  • Posts: 2,091
  • Joined: 02-May 04


Dream Kudos: 800

Re: Calculating Average annual and compound annual growth rates and future

Posted 08 August 2006 - 08:39 PM

Forum rules.
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • Icon

Reputation: 564
  • View blog
  • Posts: 18,248
  • Joined: 17-March 01


Dream Kudos: 1650

Expert In: Web Development

Re: Calculating Average annual and compound annual growth rates and future

Posted 08 August 2006 - 09:01 PM

I think what Dark_Nexus is trying to say is... while we'd be happy to assist you with your assignment, we do require you show us what you've done so far or explain exactly what you're having trouble with.

Thanks and welcome to dream.in.code!
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users