format output

I understand this to be an age old question but I have tried all the iomanip manipulators to correct this issue. My output consists of 4 columns with the last two containing float values (dollar amounts). The problem is that the last column is not aligned correctly.


 Account Number Number of Months        Initial Balance         Final Balance
      1000         9                  $2.79                  $2.85
      1234        23                  $95.04                  $100.83
      3341        10                  $0.00                  $0.00
      3221        21                  $-1.08                  $-1.08
      7462         4                  $404.14                  $409.56
      3425        11                  $4784.00                  $5007.89
      3701         4                  $99.50                  $100.67


1
2
3
cout<<setw(10)<<accNum<<setw(15)<<month<<setiosflags(ios::fixed)
<<setw(19)<<setprecision(2)<<"$"<<oldbal<<setiosflags(ios::fixed)
<<setw(19)<<setprecision(2)<<"$"<<bal<<endl;
Last edited on
Topic archived. No new replies allowed.