Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Design Operation And Evaluation Of Mobile Communications

Authors: Gavriel Salvendy ,June Wei

1st Edition

3030770249, 978-3030770242

More Books

Students also viewed these Programming questions