Problem

In this exercise, you learn how to provide a default value for a formal parameter. a....

In this exercise, you learn how to provide a default value for a formal parameter.

a. You can provide a default value for one or more of a function’s formal parameters. If a formal parameter has a default value, then you do not need to provide an actual argument for it when you call the function. Follow the instructions for starting C++ and viewing the Advanced25.cpp file, which is contained in either the Cpp7\Chap09\Advanced25 Project folder or the Cpp7\Chap09 folder. (Depending on your C++ development tool, you may need to open this exercise’s project/solution file first.) If necessary, delete the two forward slashes that appear before the system("pause"); statement, and then save the program. The program uses a value-returning function to calculate a bonus amount. The bonus rate is based on the salesperson’s code: either A or B. The user enters the bonus rate only for salespeople with an “A” code. Salespeople with a “B” code always receive a 5% bonus.

b. You provide a default value for a formal parameter in the function’s prototype, using the syntax formalParameterDataType = defaultValue. If the prototype also contains the parameter’s name, you use the syntax formalParameterDataType formalParameterName = defaultValue. Keep in mind that all formal parameters having a default value must be placed after those that do not have a default value in the function prototype. Change the function prototype so that it uses the number .05 as the default value for the bonus rate.

c. Save and then run the program. Test the program appropriately

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search