Write a program (or modify the one written for Lab 2) that displays the following menu and prompts the user for a selection. Once the selection has been made, display the selection back to the user. Then, ask the user for two numbers and perform the selected operation (+, -, *, /). Display the results back to the user (e.g. 2 + 3 = 5). When dividing, display an error message if the second number (denominator) is 0.
1) Add two numbers 2) Subtract two numbers 3) Multiply two numbers 4) Divide two numbers
9) Exit program
The program should:
HINT: The switch statement is ideal for menu-driven programs...
SAMPLE OUTPUT FOR VALID MENU SELECTION
You entered 2, subtract two numbers
SAMPLE OUTPUT FOR INVALID MENU SELECTION
You entered 5, an invalid selection
SAMPLE OUTPUT FOR ADD Please enter two numbers, separated by a space: 2 3
2 + 3 = 5
SAMPLE OUTPUT FOR DIVISION ERROR Please enter two numbers, separated by a space: 2 0
Division by zero is not possible
Q: Design a program that displays a table of the Celsius temperatures 0 through 20 and their Fahrenheit...
A: Program plan:Use “for” loop to print a table of the Celsius temperatures 0 through 20 and their Fahr...
Q: CHALLENGE 3.16.2: Alphabetic replace. ACTIVITY Replace any alphabetic character with ' in 2-characte...
A: Program://include the required header files#include <iostream>#include <string>#include ...
Q: Construct an npda corresponding to the grammar S→aABB|aAA,A→aBB|b,B→bBB|A.
A: Firstly, we will convert the given grammar into GNFS → aABB|aAAA → aBB|bB → bBB|aBB|a
Q: For problem 10RQ for Business Informaiton Systems book by Paige Baltzan, the question asked what is ...
A: The terms Collective intelligence, Knowledge management and Crowdsourcing are related to each other ...
Q: Provide a situation that encompasses Confidentiality in the CIA triad
A: Answer:Situation of Confidentiality:Confidentiality comes under the C.I.A (Confidentiality Integrity...
Q: please solve this in python //////////////// //////////////// //////////////// ////////////////
A: Program Instructions:Create three functions namely top(), body() and word() to print the different p...
Q: Eliminate all useless productions from the grammar S → aS|AB|λ, A → bA, B → AA. What language does t...
A: A useless production is basically a production which can never participate in the derivation of any ...
Q: Simplify the following equation using Boolean Identities: ~x~yz + ~xy~z + x~y~z + x~yz + xy~z + xy...
A: 1)~x~yz + ~xy~z + x~y~z + x~yz + xyz~x~yz + ~xy~z + x~y~z + x~yz + xy~z + xyz( ~x~yz + x~yz ) + ( ~x...
Q: Use K-Maps to simplify each of the following: ~x~y~z + ~xyz + ~xy~z ~x~y~z + ~xy~z + x~y~z + xy~z ~...
A: Since there are 3 variables we construct the K-Map as follows and find the minimal cover of the map ...