Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// Program reads an employee\'s hourly pay rate and the number of hours worked a

ID: 655513 • Letter: #

Question

// Program reads an employee's hourly pay rate and the number of hours worked and displays the

//wage

#include <iostream>

#include <iomanip>

using namespace std;
/* FILL IN the function prototype for getData */

int main ()

{

float hoursWorked=0, payRate=0, wage=0;
cout << fixed << showpoint;
/* WRITE code to call function getData */
wage = hoursWorked * payRate ;

cout << setw(10) << hoursWorked

<< setw(10) << payRate

<< setw(10) << wage << endl;


system("pause");

return 0;

}

//*****************************************************

/* WRITE the function heading for getData */

{

/* WRITE Code to prompt for hours worked and pay rate */

/* WRITE Code to read read hours worked and pay rate */

}

Exercise 1. Write the heading for function getData. Need to determine the (1) return type, (2) parameters passed to functions and their types, and (3) whether parameter need to be passed by value or by reference.
Exercise 2. Write the code to call function getData from main().
Exercise 3. Write the function prototype for getData. Compile your program and fix any syntax errors (note: since the body of function getData is empty, the program doesn

Explanation / Answer

// Program reads an employee's hourly pay rate and the number of hours worked and displays the wage

#include <iostream>
#include <iomanip>
#include <cstdlib> //header file for function system()
using namespace std;
/* FILL IN the function prototype for getData */
void getData(float&,float&);
int main ()
{
float hoursWorked=0, payRate=0, wage=0;
cout << fixed << showpoint;
/* code to call function getData */
getData(hoursWorked,payRate);
wage = hoursWorked * payRate ;
cout << setw(10) << hoursWorked<< setw(10) << payRate<< setw(10) << wage << endl;
system("pause");
return 0;
}

//*****************************************************

/* function heading for getData */
void getData(float& hoursWorked,float& payRate)
{
/* Code to prompt for hours worked */
cout<<"Enter hours worked: ";
/* Code to read hours worked */
cin>>hoursWorked;
/* Code to prompt for hourly pay rate */
cout<<"Enter hourly pay rate: ";
/* Code to read hourly pay rate */
cin>>payRate;
}