This program does not have any input. Instead, the main routine, called the driver, calls the Pay function, testing it with a variety of parameters.

Your job is to write the function. It should calculate the rate of pay, but in this case, the function returns the amount of pay back to the main routine.

The top part of your program should look like this:

#include <iostream>
using namespace std;
double Pay(double rate, double hours);  // Notice the semicolon. This is the declaration.

int main()
{  
   cout << "The pay for 30 hours at  $8.50 is $" << Pay(8.50, 30) << endl;
   cout << "The pay for 40 hours at $12.00 is $" << Pay(12.00, 40) << endl;
   cout << "The pay for 50 hours at $10.00 is $" << Pay(10.00, 50) << endl;
   return 0;
}
double Pay(double rate, double hours)   // No semicolon, this is the function
{                                       // that you write.   

   // You can declare local variables here that you might use in your calculation:
   
   double StraightPay, BasePay, OverTimePay, TotalPay;

      // Put your code here to do the calculation. 
     .  .  .  
      // You must return your result in one or more places. 
}

Your output should be:
The pay for 30 hours at $8.50 is $255
The pay for 40 hours at $12.00 is $480
The pay for 50 hours at $10.00 is $550

Recommended Answers

All 3 Replies

What can't you figure out? Do the math on paper first so that you can easily find the total pay. if the hours exceed 40 then you have to pay 1.5% for overtime.

We'll start on it right away sir!

Something wrong with your homework , where are you reading StraightPay, BasePay, OverTimePay, TotalPay ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.