SOURCE FILE: 035_salaryCalc_A.cpp
/*
This program illustrates how to use an if-else-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, total_pay ;
cout << "What is the hourly rate of pay?: " ;
cin >> rate ;
cout << "How many hours did you work this week?: " ;
cin >> hours ;
if (hours <= 40)
total_pay = rate * hours ;
else
total_pay = (rate * 40) + ( rate * 1.5 * (hours - 40) ) ;
/*
Similar code for the case where it is desired to perform a pair
of action if hours <= 40 and a different pair of actions if
hours > 40
if (hours <= 40)
{
cout << "You do not get OT pay.\n" ;
total_pay = rate * hours ;
}
else
{
cout << "You get OT pay.\n" ;
total_pay = (rate * 40) + ( rate * 1.5 * (hours - 40) ) ;
}
*/
cout << "Your total pay is " << total_pay << ".\n" ;
return 0;
}