Function Practice Exercise: Employee Pay
The goal of this exercise is to practice writing C++ functions by writing program that calculates the pay for an employee. This program will prompt for and read a pay rate and number of hours worked from the user. It will then echo the input information and output the calculated pay.
What to Do
- create a C++ program named
ex2_calcPay.cpp
in the Visual Studio project or create it in your IDE. - write a void function, called
getData()
, which takes two arguments and reads the pay rate and the number of hours worked. - write a value returning function, called
calcPay()
, which takes two arguments and returns the total pay for that employee. - write a void function, called
printPay()
, which takes three arguments and prints the input information and the calculated total pay. - make use of parameters and returns to pass information around, do not use global variables.
- The sample output for the program should looks like the following:
This program calculates total pay for an employee.
please enter pay rate per hour: 15.66
Please enter hours worked: 200.5
For an employee who worked 200.5 hours with a pay rate $ 15.66 per hour,
The total pay is $ 3139.83.
Press any key to continue . . .
When you are done:
- Take a screenshot of your IDE and console window after compiling and then running the program twice. The inputs that you can use are:
- the pay rate and monthly hours of a job you expect to get soon
- the pay rate and monthly hours of your dream job
- For this exercise, you will have:
ex2_calcPay.cpp
. - If you have completed Exercises 1 and 2, congratulations! Option 1 is complete! Please upload .cpp files and screenshots to URCourses.