title: Displaying aligned columns in C++
body: <p>I am currently doing a project right now where I have to display a range of integers along with 10%, 15%, and 20% discounts for the integers in columns. This is not a problem for me when the numbers have the same amount of character spaces, however this project mixes number such as 5.00 and 10.00. Because 10.00 contains five character spaces and 5.00 contains four, it throws my columns off. I know it is super nit picky but I want to fix it. Is there a way?</p>
  
  <pre><code>    #include &lt;iomanip&gt;
      #include &lt;iostream&gt;
      using namespace std;
  
      int main()
      {
          double number = 0.0;
          double tenp = 0.0;
          double fifp = 0.0;
          double twep = 0.0;
  
          cout &lt;&lt; "Original price" &lt;&lt; setw(13) &lt;&lt; "10% off" &lt;&lt; setw(20) 
               &lt;&lt; "15% off"&lt;&lt; setw(20) &lt;&lt; "20% off"&lt;&lt;endl;
  
          for (double number = 5.0; number &lt; 51; number += 5)
          {
              tenp = number - number*.10;
              fifp = number - number*.15;
              twep = number - number*.20;
  
  
              cout &lt;&lt; fixed&lt;&lt;setprecision(2);
              cout &lt;&lt;"$ " &lt;&lt; number &lt;&lt; setw(15)&lt;&lt;"$ " 
                  &lt;&lt; tenp&lt;&lt; setw(15)&lt;&lt;" $ " 
                  &lt;&lt; fifp&lt;&lt; setw(15) &lt;&lt;"$ "
                  &lt;&lt; twep &lt;&lt; endl;
  
  
  
          }
          return 0;
      }
  
  
  
      Original price      10% off             15% off             20% off
  $ 5.00             $ 4.50             $ 4.25             $ 4.00
  $ 10.00             $ 9.00             $ 8.50             $ 8.00
  $ 15.00             $ 13.50             $ 12.75             $ 12.00
  $ 20.00             $ 18.00             $ 17.00             $ 16.00
  $ 25.00             $ 22.50             $ 21.25             $ 20.00
  $ 30.00             $ 27.00             $ 25.50             $ 24.00
  $ 35.00             $ 31.50             $ 29.75             $ 28.00
  $ 40.00             $ 36.00             $ 34.00             $ 32.00
  $ 45.00             $ 40.50             $ 38.25             $ 36.00
  $ 50.00             $ 45.00             $ 42.50             $ 40.00
  Press any key to continue . . .
  </code></pre>