My code:
cout.setf(ios_base::fixed, ios_base::floatfield);
plan++;
double Annually, Monthly, Daily;
Annually = CompoundAnnually (principal, rate, years);
Monthly = CompoundMonthly (principal, rate, years);
Daily = CompoundDaily (principal, rate, years);
cout << setw(3) << plan << "\t";
cout.precision(0);
cout << setw(10) << principal << "\t";
cout.precision(1);
cout << setw(7) << rate << "%" << "\t"
<< setw(8) << years << "\t";
cout.precision(2);
cout << setw(11) << Annually << "\t"
<< setw(11) << Monthly << "\t"
<< setw(11) << Daily << "\t"
<< endl;
I had to set the decimal precision for all of these after doing it for these last three where it's necessary, because this chunk of code is within a while loop, so next time it comes around, the stuff up top is affected, which is not right. I want the rates to appear like this
2.5
5
3.5
2
instead of
2.5
5.0
3.5
2.0
but it looks like I have to make a choice between no decimal or one absolutely. UNLESS of course there is a way to close this cout.setf setting thing. Help please?