// A program to calculate the salaries for 10 employees using functions and the 'for' loop
// File: ch4prg1AllFunctions.cpp

// The specifications would go here.

#include <iostream.h>

const 	int REGULAR_HOURS = 40;             // Number of hours before overtime kicks in
const	double OVERTIME_ADJUSTMENT = 1.5;   // Overtime pay adjustment

const	int NUM_TIMES = 10;	             // Number of employees to work with


void DisplayIntroScreen();
/*
Purpose:	To output a introductory message

Receives:	NONE
Returns:	NONE
*/


void DisplayExitScreen();
/*
Purpose:	To output an exit message

Receives:	NONE
Returns:	NONE
*/


double GetRateOfPay();
/*
Purpose:	To get the rate of pay for an employee from a user

Receives: Nothing
Returns	 <payRate> , a double
*/

double GetHoursWorked();
/*
Purpose:	To get the hours worked for an employee from a user

Receives: Nothing
Returns	 <hoursWrked> ,a double
*/

void OutputSalary (double salary);
/*
Purpose:    To output the salary of an employee

Receives:   <salary>, a double
Returns	    NONE
*/



double CalculateSalary(double rate, double hours);
/*
Purpose:	To calculate an employee's salary

Receives:	<hours> a double, <rate> a double
Returns:	 <fullSalary>
*/

void main()
// Purpose:  to calculate salaries for 10 employees

// Receives: NONE
// Returns:	 NONE
{
	double rateOfPay;
        double hoursWorked;  // can be a fraction of an hour
       	
	double salary;

	DisplayIntroScreen();

	for (int count = 0; count < NUM_TIMES; count++)
        {
	   rateOfPay = GetRateOfPay();
	   hoursWorked = GetHoursWorked();

	   salary = CalculateSalary(rateOfPay, hoursWorked);
	   OutputSalary(salary);
	 }
	DisplayExitScreen();

}

double GetRateOfPay()
{	double payRate;
	cout << "Please enter an employee's rate of pay ";
	cin >> payRate;
	return payRate;
}

double GetHoursWorked()
{	double hoursWrked;
	cout << "Please enter the number of hours worked for an employee ";
	cin >> hoursWrked;
	return hoursWrked;
}

void OutputSalary (double salary)
{	cout << "The employee's salary is: " << salary << endl;
}



double CalculateSalary(double rate, double hours)
{	double regularSalary;
	double overtimeSalary;
        double overtimeRateOfPay;
	double fullSalary;
	double hoursWorked;  // can be a fraction of an hour

	
	if (hours > REGULAR_HOURS)
	{	regularSalary = REGULAR_HOURS * rate;
		overtimeRateOfPay = rate * OVERTIME_ADJUSTMENT;
		overtimeSalary = (hours - REGULAR_HOURS) *   overtimeRateOfPay;
		fullSalary = regularSalary + overtimeSalary;
   }
	else
	{ 	fullSalary	 = hours* rate;
	}

	return fullSalary;
}

void DisplayIntroScreen()
{	cout << "Welcome to the Employee Salary Program\n";
}

void DisplayExitScreen()
{	cout << "The Employee Salary Program is now exiting\n";
}