Question: 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 5 to store the results of the calculator opcrations. Initialize the array to zero.
[5 Marks]
Write a function display Menu() that outlines the menu options available to the user:
Addition
Subtraction
Multiplication
Division
[10 Marks]
Based on the menu option selected, describe how you would handle the user's choice using a switch statement:
Choice 1: Prompt the user for two numbers and add them together. Store the result in the array at the first index.
Choice 2: 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 3: Prompt the user for two numbers and multiply them. Store the result in the array at the third index.
Choice 4: 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.
[15 Marks]
Write the code for the main function that would use a loop (of your choice) to repeatedly display the menu using the display Menu0 function, read the user's choice, and perform the corresponding operation.
[20 Marks]
 Imagine you are writing a program that simulares a simple calculator.

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