Question
This is an example of using default parameters. The function will accept up to 2 parameters and calculate a gross pay The function header is
This is an example of using default parameters.
The function will accept up to 2 parameters and calculate a gross pay
The function header is similar to
float calcGrossPay(float hours, float rate)
return hours * rate
if there is no rate in the function call, the pay rate defaults to $8.75
if no hours are in the function call, the hours defaults to 20 hours
call the function three times to ensure the function works
- calcGrossPay()
- calcGrossPay(hours, rate)
- calcGrossPay(hours)
float calcGrossPay(float hours=20 float rate=8.75)
{
return hours * rate
}
Output is from main
calcGrossPay( )
oputput should be hours are ?????.??
rate is ?????.??
gross pay is ?????.??
calcGrossPay(5, 3.33)
oputput should be hours are 5.00
rate is 3.33
gross pay is 16.65
calcGrossPay(5)
oputput should be hours are 5.00
rate is 8.75
gross pay is 43.75
call the function three times to ensure the function works
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started