interest calculation

hi im new to C++ and im trying to find the interest of an amount i have to enter and intial amount, enter a monthly deposit, a monthly interest rate and a duration in months and then to find the total amount after the set duration, my problem is i cant figure out how to add the interest rate after each month this is my code so far.

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>
#include "account.h"         // click on the link to see class Account
using namespace std;
void main(void)
{

double mintr, ibal, mdep, dur, beeb;

cout << "Initital Balance" << endl;
cin >> ibal;

cout << "monthly deposit" << endl;
cin >> mdep;

cout << "add interest rate" << endl;
cin >> mintr;

cout << "duration" << endl;
cin >> dur;

  Account stdAccount(ibal, mintr); 

    double jim = (1 + mintr/100.0);
  int i = 0;
  for(i;i<dur;i++)
  {

	ibal += mdep*jim;

  }


  cout << ibal << endl;
	  

  
 
  
  
}




please help thanks
Your math is bad.

I would recommend that you try to do this in a spreadsheet first, to correct your math.
When you can do it right in a spreadsheet, the algorithm will become obvious.

Then coding it up in C++ should be a trivial exercise.
Last edited on
Topic archived. No new replies allowed.