Write the definition of the function getHoursRate that prompts the user to input the hours worked and rate per hour to initialize the variables hours and rate of the function main. b. Write the definition of the value-returning function payCheck that calculates and returns the amount to be paid to an employee based on the hours worked and rate per hour. The hours worked and rate per hour are stored in the variables hours and rate, respectively, of the function main. The formula for calculating the amount to be paid is as follows: For the first 40 hours, the rate is the given rate; for hours over 40, the rate is 1.5 times the given rate. C. Write the definition of the function printCheck that prints the hours worked, rate per hour, and the salary. d.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Write C++ code for the following programming exercise. (All inputs must be done in main() and all functions must be called from main().

16.
Consider the definition of the function main:
int main ()
{
int x, Yyi
char z;
double rate, hours;
double amount;
}
The variables x, y, z, rate, and hours referred to in items a through f
below are the variables of the function main. Each of the functions
described must have the appropriate parameters to access these vari-
ables. Write the following definitions:
b.
Write the definition of the function getHoursRate that prompts
the user to input the hours worked and rate per hour to initialize
the variables hours and rate of the function main.
Write the definition of the value-returning function payCheck that
calculates and returns the amount to be paid to an employee based
on the hours worked and rate per hour. The hours worked and rate
per hour are stored in the variables hours and rate, respectively,
of the function main. The formula for calculating the amount to be
paid is as follows: For the first 40 hours, the rate is the given rate;
for hours over 40, the rate is 1.5 times the given rate.
C.
Write the definition of the function printCheck that prints the
hours worked, rate per hour, and the salary.
d.
g.
Write the definition of the function main that tests each of these
functions.
Transcribed Image Text:16. Consider the definition of the function main: int main () { int x, Yyi char z; double rate, hours; double amount; } The variables x, y, z, rate, and hours referred to in items a through f below are the variables of the function main. Each of the functions described must have the appropriate parameters to access these vari- ables. Write the following definitions: b. Write the definition of the function getHoursRate that prompts the user to input the hours worked and rate per hour to initialize the variables hours and rate of the function main. Write the definition of the value-returning function payCheck that calculates and returns the amount to be paid to an employee based on the hours worked and rate per hour. The hours worked and rate per hour are stored in the variables hours and rate, respectively, of the function main. The formula for calculating the amount to be paid is as follows: For the first 40 hours, the rate is the given rate; for hours over 40, the rate is 1.5 times the given rate. C. Write the definition of the function printCheck that prints the hours worked, rate per hour, and the salary. d. g. Write the definition of the function main that tests each of these functions.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning