Program
14
C++
Konrad Dzwonkiewicz
Using Function Over Loading
Create two functions with the same name, use the name Calc_ave (see The fat hang out on functions)
These functions will take as input either three integer values or three float values and as the name indicates, calculate the average of these three numbers.
Your program will first as for three integers to be input. Call the function Calc_ave and print out their average in the function (return nothing)
Next ask for three floats and call the function Calc_ave where you print out their average.
Sample Run…
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please enter three integers: 65 85 75
Average is: 75
Please enter three decimal numbers: 75.25 88.92 45.83
Average is: 70.00
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Next, do a similar process where two other functions, called Get_result, will be called twice. (This is still overloading the function.) The first call will take three doobles I mean three doubles and return the largest of the three. ( printing out in main)
The other function, called Get_result will pass in three char values and return whether or not any are capitalized ( hint: check…if (letter<91) status = 1;)
Also, for this last function have a pass by reference variable 9called count) that will keep track how many are capitalized.
Sample Run…
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please enter three doubles: 123.456 876.23 999.234
Largest is: 999.234
Please enter 3 letters: d z W
Capitals: YES Amount: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~