Answered step by step
Verified Expert Solution
Link Copied!

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 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]
image text in transcribed

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

Students also viewed these Databases questions