C++ Arithmetic Operator Compute the full overtime pay possibilities

Description

C++ Arithmetic Operator Compute the full overtime pay possibilities

#include <iostream>
using namespace std;
#include <stdio.h>
int main()/*from w ww  .  j  av a 2 s .  c om*/
{
   int hours;
   float dt, ht, rp, rate, pay;
   cout << "\n\nHow many hours were worked? ";
   cin >> hours;
   cout << "\nWhat is the regular hourly pay? ";
   cin >> rate;

   if (hours > 50)
   {
      dt = 2.0 * rate * (float)(hours - 50);
      ht = 1.5 * rate * 10.0;
   }
   else
   {
      dt = 0.0;
   }
   if (hours > 40)
   {
      ht = 1.5 * rate * (float)(hours - 40);
   }
   // Regular Pay
   if (hours >= 40)
   {
      rp = 40 * rate;
   }
   else
   {
      rp = (float)hours * rate;
   }
   pay = dt + ht + rp;   // Add three components of payroll.
   printf("\nThe pay is %.2f", pay);
   return 0;
}



PreviousNext

Related