#include <iostream>
using namespace std;
int main ()
{
double deposit, ratein, rate, r1, r2; int i, j=0, years; char repeat;
bool prompt;
do
{
prompt = false;
cout<<"Initial deposit? ";
cin>>deposit;
cout<<endl;
cout<<"Interest rate in percentage? ";
cin>>rate;
cout<<endl;
cout<<"Number of years? ";
cin>>years;
while (years > 20)
{
cout<<"Enter number of years between 5 and 20: ";
cin>>years;
}
cout<<endl;
if (years < 5) years = 5;
rate = 1 + (ratein/100);
r1 = rate - .1;
r2 = rate + .1;
for (i=1; i<=years; i++){
cout<<i<<" "<<deposit<<endl;
for (j; j<=i; j++){
deposit *= rate;
}
}
cout<<"Would you like to try again? (Y/N) ";
cin>>repeat;
if (repeat == 'y' || repeat == 'Y') {
prompt = true;
}
cout<<endl;
} while (prompt);
system("PAUSE");
return 0;
}
I'm trying to do this without the pow operator. I get the years output correct but my initial deposit doesn't seem to be affected, it's not changing. I don't know how to go about trying to assign a new value to 'deposit' so that it equals the deposit amount times the interest for its respective amount of years and outputs the amount for each year. Thanks for any help.

New Topic/Question
Reply


MultiQuote



|