Help with output formatting
I'm trying to get my output to look like this:
year 1 year 2 year 3 year 4 year 5
6%:
7%: THE ACTUAL ACCOUNT BALANCE DATA SHOULD APPEAR
8%: IN HERE NICELY FORMATTED
9%:
10%:
11%:
12%:
My output is like this:
year1 year2 year3 year4 year5 <---the y in year1 is actually aligned with the 1 below it
6% 1060 1123 1190 1261 1336
7% 1070 1144 1224 1309 1400
8% 1080 1166 1259 1359 1467
9% 1090 1188 1294 1410 1536
10% 1100 1210 1331 1464 1610
11% 1110 1232 1367 1517 1683
12% 1120 1254 1404 1572 1760
how do i get these numbers to xxxx.xx format AND align this stuff up? I've been toiling with this for a couple of days now and i still cant get it...here's my source code
#include <iostream.h>
#include <stdlib.h>
#include <iomanip.h>
using namespace std;
int main ()
{
int 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 << (interest * 100) << "%";
for (int x=0;x<5; x++)
{
amt = amt+(amt * interest);
cout << setw(8) << amt;
}
amt=1000;
interest=interest+.01;
cout << endl;
}
system("pause");
return 0;
}