basic compound interest program

Sorry guys, I am very new to programming. For class we have to make a compound interest calculator to calculate future value after 4 years. A buddy of mine helped me out but I can only seem to get it to calculate for the first year. I am completely lost, any help would be greatly appreciated. Thanks! Here is my source code. What am I doing wrong??

#include<iostream>
#include<iomanip>
using namespace std;



int main(int args, char arg[]){
double money=0.0;
double interest=0.0;
int year=0;
int C=0;
double y;

cout<<"Enter an amount to invest"<<endl;
cin>>money;

cout<<"Enter an annual interest rate"<<endl;
cin>>interest;

cout<<"Enter how many years you want calculated"<<endl;
cin>>year;

do{
y=money+(money*interest/100);
C++;

}while (C<=year);

cout<<y;


system("pause");
}
Just rearrange your do while loop to this:
1
2
3
4
5
6
7
do{
money+=(money*(interest/100));
C++;

}while (C<year);

cout<<money;
Omg thank you so much!!!
No prob.
Topic archived. No new replies allowed.