title: Where and How to format a C++ code to 2 decimal places
body: <p><strong>◾Use output statements to display input data and calculation results; display decimal values formatted to two decimal places.</strong>  <strong>This is where I am having difficulties!</strong> Everything else has been done for this particular project so for example when u use 4.4444 for pay rate and 10 for hours it should print out that regular pay is 44.44!  not 44.444!</p>
  
  <pre><code>{
  // declare variables
  int Id = 0;
  double hours = 0.00;
  double payrate = 0.00;
  char ucode = 'A';
  double rpay = 0.00;
  double opay = 0.00;
  double gpay = 0.00;
  double ftax = 0.00;
  double npay = 0.00;
  
  cout &lt;&lt;"\nWelcome Please Enter Employee Info";
  
  //Input Data from keyboard
  cout &lt;&lt; "\nEnter Employee's ID ";
  cin &gt;&gt; Id;
  cout &lt;&lt; "\nEnter Employee's Hours worked ";
  cin &gt;&gt; hours;
  cout &lt;&lt; "\nEnter Employee's Pay Rate $";
  cin &gt;&gt; payrate;
  cout &lt;&lt; "\nEnter Employee's union code ";
  cin &gt;&gt; ucode;
  cout &lt;&lt; "\nEmployee's Id " &lt;&lt; Id &lt;&lt; "\nEmployee's Hours " &lt;&lt; hours &lt;&lt; "\nEmployee's Payrate " &lt;&lt; payrate &lt;&lt; "\nEmployee's Union Code " &lt;&lt; ucode;
  //Calculate regular pay and/or overtime pay. 
  if ( hours &lt;= 40 ){
    rpay = hours * payrate;
    gpay = rpay;
    cout&lt;&lt; "\nGross pay is $" &lt;&lt; gpay;}
  
  if ( hours &gt; 40 ){
     rpay = 40 * payrate;
     opay = payrate * (1.5 *(hours-40));
     gpay = rpay + opay;
     cout&lt;&lt; "\nGross pay is $" &lt;&lt; gpay;}
  //Calculate the Gross Pay.   
  if ( gpay &lt;= 1000 ) {
     ftax = .10 * gpay;
     cout &lt;&lt; "\nThe Federal tax due is $" &lt;&lt; ftax;
     }
  
   else if ( gpay &gt; 1000 &amp;&amp; gpay &lt;= 2000){
     ftax = .15 * gpay;
     cout &lt;&lt; "\nThe Federal tax due is $" &lt;&lt; ftax; 
       }
  
    else if ( gpay &gt; 2000){
     ftax = .25 * gpay;
     cout &lt;&lt; "\nThe Federal tax due is $" &lt;&lt; ftax;
       }
  //Calulating Netpay.     
  switch ( ucode )
  {
         case 'A' : cout &lt;&lt; "\nEmployee owes $25 to Union ";
                    npay = (gpay - (ftax + 25));
                    cout &lt;&lt; "\nEmployee's Net Pay is $" &lt;&lt; npay;
                    break;
  
         case 'a' : cout &lt;&lt; "\nEmployee owes $25 to Union ";
                    npay = (gpay - (ftax + 25));
                    cout &lt;&lt; "\nEmployee's Net Pay is $" &lt;&lt; npay;
                    break;
  
         case 'B' : cout &lt;&lt; "\nEmployee owes $50 to Union ";
                    npay = (gpay - (ftax + 50));
                    cout &lt;&lt; "\nEmployee's Net Pay is $" &lt;&lt; npay;
                    break;
  
         case 'b' : cout &lt;&lt; "\nEmployee owes $50 to Union ";
                    npay = (gpay - (ftax + 50));
                    cout &lt;&lt; "\nEmployee's Net Pay is $" &lt;&lt; npay;
                    break;
  
         case 'C' : cout &lt;&lt; "\nEmployee owes $75 to Union ";
                    npay = (gpay - (ftax + 75));
                    cout &lt;&lt; "\nEmployee's Net Pay is $" &lt;&lt; npay;
                    break;
  
         case 'c' : cout &lt;&lt; "\nEmployee owes $75 to Union ";
                    npay = (gpay - (ftax + 75));
                    cout &lt;&lt; "\nEmployee's Net Pay is $" &lt;&lt; npay;
                    break;          
         default:
                    cout &lt;&lt; "\nThere is no such Union Code ";
                    npay = (gpay - (ftax + 0));
                    cout &lt;&lt; "\nEmployee's Net Pay is $ " &lt;&lt; npay;
                    }
         cout &lt;&lt; "\nThank You for using our software, Please Enjoy the rest of your Day! \n ";
  </code></pre>