Island of Manhattan Interest after 400 years.

According to the legend, the island of Manhattan was purcased from the native indian population in 1626 for 24 dollars. Assuming this money was invested in a Dutch bank paying 5 %
simple interest per year, costruct a table in C++ showing how much money the native population would have at the end of each 50- year period, starting in 1626 and ending 400 years latter.
I'm having problems when i try to calculate the total amount of money every 50 year period. I don't know how to make the last column of my output to increment
Thanks in advance.



2.
simple Interest = Principal amount * Interest rate * years


3.Code


#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
int main ()

{
float year;
double rate, interest, totMoney;

year = 1626;
rate = .05;

cout << " Year Interest gained Total Money" << endl;
cout << "-----------------------------------------------"<< endl;
cout << endl;




while( year <= 2026)
{


interest = 24 * .05* 50;
totMoney = 24 + interest;


cout << setw(7) << year << setw(15) << interest << setw(15)<< totMoney << endl;

cout << endl;

totMoney ++;

year += 50;


}




return 0;
}
Why would the Indians Natives invest 50 bucks in any bank?

Simple intrest, by the way, is calculated (how I learned it):

A = P (1+i)n

Where:

A = amount at maturity (what the end amount is)
i = intrest (in decimal form)
n = investment periods

Where did you get this assignment?
Last edited on
Thanks for the simple interest formula, can you also help me with the code?
Firstly, you haven't initialized totMoney. You should initialize it to 24.

Second, this formula

interest = 24 * .05* 50;

is wrong in a few ways. Instead of .05, it should be 1.05. Yes, multiplying by .05 will give you the interest, but that will only be for one year. To properly add it up for every year, you need to multiply by 1.05. You should also not multiply by 50, but have 1.05 raised to the power of 50. And, instead of 24, it should be the total money at the beginning of the period (i.e. totMoney).

Also note that this won't give you the interest accrued for the period but rather the final amount at the end of the period, so there's no need to add up the interest accrued every time as the formula does it for you.

totMoney ++;

You shouldn't increment by one here. It doesn't make any sense unless the bank has some kind of weird promotion where they give you a buck every 50 years for being a valuable customer or something.
Last edited on
Thanks, I just make some adjustments to my code and i think it works perfectly. Thanks for the hints. This is the new code

{
float year;
double rate, interest, totMoney;

year = 1626;
rate = .05;

cout << " Year Interest gained Total Money" << endl;
cout << "-----------------------------------------------"<< endl;
cout << endl;






for ( year = 1626; year<=2026; year+= 50 )
{


interest = 24*(year-1626)*rate;
totMoney = interest + 24;

cout << setw(7) << year << setw(15) << interest << setw(15)<< totMoney << endl;

cout << endl;

totMoney ++;



}


return 0;
}

Unfortunately, your code is still not calculating simple interest correctly.

In 1676, the total amount should be (approx.) $275.22(I rounded up to the next cent but banks will always round down).

According to your program, the amount in 1676 is only $84. If you owned a bank, you would have to answer to a lot of angry customers. This doesn't take into account the $1 that you mysteriously add afterwards (which gets overwritten in the next iteration). Hint: do not do this: totMoney ++;

In 1726, the total amount should be (approx.) $3156.03.

According to your program, the amount in 1726 is only $144. Congratulations, you have just screwed your customer of 100 years out of $3012.03 :D

The problem with your formula is you are finding how much interest would be accrued on $24 in one year and multiplying it by how many years have passed. What you should do is implement Danny Toledo's formula:

A = P (1+i)n


Where P would be the total amount computed in the last iteration, (1+i) is 1.05, n is 50, and A is the total amount at the end of the present 50 year period (Hint: set this to P in the next iteration).
Topic archived. No new replies allowed.