Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Imagine you are writing a program that simulares a simple calculator. The calculator will perform basic arithmetic operations ( addition , subtraction, multiplication, and division
Imagine you are writing a program that simulares a simple calculator. The calculator will perform basic arithmetic operations addition subtraction, multiplication, and division
Define an array of size to store the results of the calculator opcrations. Initialize the array to zero.
Marks
Write a function display Menu that outlines the menu options available to the user:
Addition
Subtraction
Multiplication
Division
Marks
Based on the menu option selected, describe how you would handle the user's choice using a switch statement:
Choice : Prompt the user for two numbers and add them together. Store the result in the array at the first index.
Choice : Prompt the user for two numbers and subtract the second number from the first. Store the result in the array at the second index.
Choice : Prompt the user for two numbers and multiply them. Store the result in the array at the third index.
Choice : Prompt the user for two numbers and divide the first by the second, handling division by zero appropriately. Store the result in the array at the fourth index.
Marks
Write the code for the main function that would use a loop of your choice to repeatedly display the menu using the display Menu function, read the user's choice, and perform the corresponding operation.
Marks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started