mustish1
asked on
Needs help in output
Hi guy: Can any one please help me that why it shows only year1 why it not shows the rate of the rest of the years in the program ? Thanks.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int principal = 1000;
int years = 1;
double balance = 0.0;
double rate = 0.03;
do
{
cout << "Year" << years << ":" << endl;
while (rate < .06)
{
balance = principal * pow(1 + rate, years);
cout << fixed << setprecision(0);
cout << " Rate " << rate * 100 << "%: $";
cout << setprecision(2) << balance << endl;
rate +=.01;
}
years +=1;
} while (years < 6);
system("Pause");
return 0;
}
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int principal = 1000;
int years = 1;
double balance = 0.0;
double rate = 0.03;
do
{
cout << "Year" << years << ":" << endl;
while (rate < .06)
{
balance = principal * pow(1 + rate, years);
cout << fixed << setprecision(0);
cout << " Rate " << rate * 100 << "%: $";
cout << setprecision(2) << balance << endl;
rate +=.01;
}
years +=1;
} while (years < 6);
system("Pause");
return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER