SOURCE FILE: 037_salaryCalc_B.cpp



/*
    This program illustrates how to use a simple if-statement to calculate pay
    in a situation where overtime is a possibility.
*/

#include <iostream>
#include <math.h>
using namespace std ;

int main (void)
{
  double rate, hours, pay ;
  cout << "What is the hourly rate of pay?: " ;
  cin >> rate ;
  cout << "How many hours did you work this week?: " ;
  cin >> hours ;

  pay = rate * hours ;

  if  (hours > 40) 
      pay = pay + ( 0.5 * rate * (hours - 40) ) ;

  cout << "Your total pay is " << pay << ".\n" ;

  return 0;
}