D
Drakscon
Some one helped out but completely confused me. this is a senario so i
can take it into the actually program im using(variables a, b, c, d are
generic but i have commented about what they are for)
Im trying to get the compounded interest so that it will work for more
than just annually. I want the user of this program to be able to do
semi annually or monthly even some other defined by the user.
The formula i was given is balance = balance + (balance* (rate/100))
This is my code. Any input is welcome
int main()
{
double a,b,c,d;//a is amount to be invested, b is years
invested
//c is compound time, d is interest rate
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++){
for(int h=0;h<c;i++){
a=a+(a*(d/100));
}
}
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;
}
can take it into the actually program im using(variables a, b, c, d are
generic but i have commented about what they are for)
Im trying to get the compounded interest so that it will work for more
than just annually. I want the user of this program to be able to do
semi annually or monthly even some other defined by the user.
The formula i was given is balance = balance + (balance* (rate/100))
This is my code. Any input is welcome
int main()
{
double a,b,c,d;//a is amount to be invested, b is years
invested
//c is compound time, d is interest rate
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++){
for(int h=0;h<c;i++){
a=a+(a*(d/100));
}
}
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;
}