I have been working on this program for several days.I have it compiling but it will not calculate the employees gross pay or total gross can anyone help.
// Grosspay9.cpp
//
// This program displays each employee's gross pay
//and the total gross pay
#include <iostream>
#include <iomanip>
using namespace std;
//function prototypes
//
// ADD STATEMENT 1 BELOW WHICH IS THE FUNCTION PROTOTYPE FOR THE
// FUNCTION NAMED "getGrossPay"
// THE FUNCTION RETURNS A DOUBLE VALUE
// THE FUNCTION RECEIVES TWO DOUBLE VALUES
double getGrossPay ();
double getTotalGross( double , double );
int main()
{
//declare variables
//
// ADD STATEMENT 2 BELOW TO DECLARE A DOUBLE VARIABLE NAMED
// "hoursWkd" AND INITIALIZE IT TO BE ZERO
double hoursWkd =0.0;
double payRate = 0.0;
double grossPay = 0.0;
double totalGross = 0.0; //accumulator
//display output with two decimal places
//
// ADD STATEMENT 3 BELOW TO OUTPUT NUMBERS WHICH WILL
// HAVE TWO DIGITS TO THE RIGHT OF THE DECIMAL.
cout << fixed << setprecision(2);
//
cout << "Grosspay9 Program Output.\n\n";
//get hours worked
cout << "Hours worked (negative number to end): ";
//
// ADD STATEMENT 4 BELOW TO INPUT THE HOURS WORKED
cin >> hoursWkd;
//
// ADD STATEMENT 5 BELOW WHICH IS A WHILE LOOP THAT
// CONTINUES TO EXECUTE AS LONG AS HOURS WORKED IS
// GREATER THAN OR EQUAL ZERO
while (hoursWkd >= 0)
{
//get pay rate
cout << "Pay rate: ";
//
// ADD STATEMENT 6 BELOW TO INPUT THE PAY RATE
cin >> payRate;
//
//calculate and display gross pay
//
// ADD STATEMENT 7 BELOW WHICH CALLS THE FUNCTION "getGrossPay"
// THE FUNCTION RETURNS A VALUE TO GROSS PAY
// THE FUNCTION RECEIVES HOURS WORKED AND PAY RATE
double getGrossPay = (hoursWkd * payRate);
cout << "Gross pay: $" << grossPay << endl;
//
//accumulate gross pay
//
// ADD STATEMENT 8 BELOW WHICH CALLS THE FUNCTION "getTotalGross"
// THE FUNCTION RETURNS A VALUE TO TOTAL GROSS
// THE FUNCTION RECEIVES TOTAL GROSS AND GROSS PAY
totalGross += grossPay ;
//
//get hours worked
cout << "Hours worked (negative number to end): ";
//
// ADD STATEMENT 9 BELOW WHICH INPUTS HOURS WORKED
cin >> hoursWkd;
} //end while
cout << endl << "Total gross pay: $" << totalGross << endl;
cout << "\n\n";
system("pause");
return 0;
} //end of main function
//*****function definitions*****
//
// ADD STATEMENT 10 BELOW WHICH IS THE FUNCTION HEADER FOR THE
// FUNCTION "getGrossPay"
// THE FUNCTION RETURNS A DOUBLE VALUE
// IT RECEIVES A DOUBLE VARIABLE NAMED "hours"
// IT RECEIVES A DOUBLE VARIABLE NAMED "rate"
double getGrossPay (double hours, double rate)
{
double getGrossPay = 0.0;
if (hours <= 40)
getGrossPay= hours * rate ;
else
getGrossPay = hours * rate + (hours - 40) * rate / 2;
//end if
return getGrossPay;
} //end of getGrossPay function
double getTotalGross(double total, double gross)
{
total += gross;
return total;
} //end of getTotalGross function