Accumulated Interest

When Bongis new baby sipho was born she opened a savings account with R1000.on each birthday starting with the first,the bank added interest of 4.5%OF THE BALANCE AND BONGI ADDED ANOTHER R500 to the account. write a loop that will calculate how much money was in the account on Siphos 18th birthday.

how do i calculated the accumulated intereset to the balance?? where am i going wrong

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  # include <iostream>
using namespace std;

int main()
{ const float yearlyinterest=(4.5/100);
    float totalsavings,inclofintersetamount,yearlytotal;
    float savamount,birthday,interest,accinterest;

cout<<"enter a bank balance "<<endl;
cin>>savamount;

yearlytotal=accinterest;
birthday=1;

while( birthday<=18)


    { // calculate inital interest
        interest=savamount*yearlyinterest;

        totalsavings=savamount+interest;
        cout<<"total savings:"<<totalsavings;
       //caluculate accumulated interest. 
        accinterest=totalsavings*yearlyinterest;
        cout<<"\taccumulated interest"<<accinterest<<endl;
        // calculation of the yearlytotal including savings and interest
        yearlytotal=totalsavings+accinterest;


           yearlytotal+=totalsavings;

           cout<<"\tyearlytotal: "<<yearlytotal;
           birthday++;

        } 




return 0;

}
Your calculations make no sense. The calculation is this, 18 times, with total = 1000 at the start.

1
2
total = total * 1.045;
total = total + 500;


Last edited on
Ok so how do i then incoprorate the 18th birthday part.......were i have to calculate interest for 18years on the bank balance
Last edited on
were i have to calculate interest for 18years on the bank balance

That doesn't seem to be in the original question you showed us, but if you want to know that as well, you can.

You know what the starting balance was, right? And you know what the ending balance was? So you can calculate how much the balance increased by, yes?

increase = final_balance - start_balance;

That increase is part from interest payments, and part from more money being put in, right?

You know how much of that increase was from more money being put in, so can you think of a way to calculate how much of that increase was from interest?
Last edited on
i have to calculate interest for 18years on the bank balance

For what it's worth, you don't have to calculate the total interest paid. You just have to calculate the final balance, which includes 18 interest payments and 18 deposits. Repeater has shown you how to do that.

I think you're missing the fact that Repeater's code needs to inside a loop. Each time through the loop, his code updates total to contain the balance for the current year. Then then next time through the loop, it uses the previous year's balance to compute the current year's.
Indeed. Dead horse flogging alert:

1
2
3
4
5
6
float total = 1000;
int count = 18;
while (count--)
{
    total = (total * 1.045) + 500;
}

ok thank you so much for you assisstance
Topic archived. No new replies allowed.