D
Drakscon
Im trying to get the compounded interest to go back only being
compounded annually. I want the user of this program to be able to do
semi annually of monthly or some other.
This is my code. Any input is welcome
int main()
{
double a,b,c,d,e;//a is amount to be invested, b is years invested
//c is compound time, d is interest rate, e is the final ammount
char ch;//allows user to enter another investment
do{
system("cls");
cout<<"enter an ammount to invest ";
cin>>a;
cout<<"Enter the years to allow to mature ";
cin>>b;
cout<<"How many times a year will it be compounded? ";
cin>>c;
cout<<"What is the rate ";
cin>>d;
for(int i=0;i<b;i++){
a=a+(a*(d/100));
e=pow(a,c);
}
cout<<"After "<<b<<" years. You have now "<<e<<" dollars in the
account\n";
cout<<"Would you like to run another? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
return 0;
}
compounded annually. I want the user of this program to be able to do
semi annually of monthly or some other.
This is my code. Any input is welcome
int main()
{
double a,b,c,d,e;//a is amount to be invested, b is years invested
//c is compound time, d is interest rate, e is the final ammount
char ch;//allows user to enter another investment
do{
system("cls");
cout<<"enter an ammount to invest ";
cin>>a;
cout<<"Enter the years to allow to mature ";
cin>>b;
cout<<"How many times a year will it be compounded? ";
cin>>c;
cout<<"What is the rate ";
cin>>d;
for(int i=0;i<b;i++){
a=a+(a*(d/100));
e=pow(a,c);
}
cout<<"After "<<b<<" years. You have now "<<e<<" dollars in the
account\n";
cout<<"Would you like to run another? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
return 0;
}