Question: You will write a C++ program that demonstrates the use of overloaded functions by displaying two numbers. You will write four functions that use function

You will write a C++ program that demonstrates the use of overloaded functions by displaying two numbers. You will write four functions that use function name overloading to take care of each one of the four scenarios listed below. In other words, in addition to your main() function, you will write four additional functions that all have exactly the same name, but different input types (see below for details).

Your main() function should first ask the user to input a menu choice number to tell the program which one of the following input entry combinations they will use. Here are the menu choices:

1. When both numbers are integers

2. When the first number is an integer and the second number is a float

3. When the first number is a float and the second number is an integer

4. When both numbers are floats

Any other option is invalid. If any number outside the range 1-4 is entered as a menu choice, your program should display a message and exit (return).

Next, here are the four scenarios you may face depending on the menu choice that is made previously:

1. If the user entered menu choice 1 above, you may assume that both numbers are integers. Your program should read them into appropriate variables, then call the appropriate function (that takes two integers as input arguments) to display them as they were entered.

2. If the user entered menu choice 2 above, you may assume that the first number was an integer and the second number was a float. Your program should read them into appropriate variables, then call the appropriate function (that takes one integer followed by one float as input arguments), which should round up the float to the next highest integer, then display the two integers.

3. If the user entered menu choice 3 above, you may assume that the first number was an float and the second number was a integer. Your program should read them into appropriate variables, then call the appropriate function (that takes one float followed by one integer as input arguments), which should round down the float to the next lowest integer, then display the two integers.

4. If the user entered menu choice 4 above, you may assume that both numbers are floats. Your program should read them into appropriate variables, then call the appropriate function (that takes two floats as input arguments), which should round down the first float to the next lowest integer, and round up the second float to the next highest integer, then display the two integers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!