here you go:
Code:
#include <iostream.h>
#include <stdlib.h>
#include <iomanip.h>
int main ()
{
float amt=1000;
float interest=.06;
cout << setw(12) << "year1 ";
cout << setw(8) << "year2 ";
cout << setw(8) << "year3 ";
cout << setw(8) << "year4 ";
cout << setw(8) << "year5 " << '\n';
for (int t=0; t<7; t++)
{
cout.setf (ios::fixed);
cout << setw(4) << setprecision(0) << (interest * 100) << "%";
for (int x=0; x<5; x++)
{
amt = amt+(amt * interest);
cout << setw(8) << setprecision(2) << amt;
}
amt=1000;
interest=interest+.01;
cout << endl;
}
system("pause");
return 0;
}
cout.setf (ios::fixed) will make sure that all floats will output with decimal points even if they are 0's
setprecision tells the program to how many decimals to output
One basic comment, in your original code you had atm as a int, which cannot hold decimal points..... so i changed it to a float.
P.S. I know there is a way to incorporate the ios::fixed right into cout, but i forgot how to do it exactly and i do not rlly feel like looking it up so if you wish to it as such, look it up