Question: Calculator Using Function Pointers) Using the techniques you learned in Fig. 7.28, create a text-based, menu-driven program that allows the user to choose whether to

Calculator Using Function Pointers) Using the techniques you learned in Fig. 7.28, create a text-based, menu-driven program that allows the user to choose whether to add, subtract, multiply or divide two numbers. The program should then input two double values from the user, perform the appropriate calculation and display the result. Use an array of function pointers in which each pointer represents a function that returns void and receives two double parameters. The corresponding functions should each display messages indicating which calculation was performed, the values of the parameters and the result of the calculation. In both cases, display the value to 2 digits of precision. Note: do not accept invalid menu selections, print an error message and ask the user to try again. Furthermore, if the user chooses division but enters 0 as the divisor, do not accept the entry, print an error message and ask the user to enter another number instead.

===CalculatorMenu===


Pleaseselectfromtheoptionsbelow:


(0)Addanumbertoanother.

(1)Subtractanumberfromanother.

(2)Multiplyanumbertoanother.

(3)Divideanumberbyanother.


Enteryourselection:-1

Invalidselection!

Enteryourselection:3

Enteranumber:25.00

Enteranothernumber:0.00

Error:attemptingtodividebyzero!

Enteranothernumber:0.05

Dividing25.00by0.05...

Theresultis:500.00





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 Programming Questions!