Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that functions as a calculator for 16-bit signed integers. It s

ID: 3854903 • Letter: C

Question

Create a program that functions as a calculator for 16-bit signed integers. It should display the current value and a menu that asks the user to make a selection. The text on your console screen would look like the following (10 is just an example value, your starting value should be 0):

Current value: 10
Error: None
1. Add
2. Subtract
3. Multiply
4. Divide
5. Exit program

When the user chooses a math operation, he/she would be asked to enter a number and the calculation would be performed. The value shown as the current value would be updated.

If an error occurs, the type of error should be indicated, otherwise you should indicate None for no error. You can detect the error using your C code portion based upon the values returned to you from assembly. For instance, you could detect out of range errors based upon what is returned from assembly, where out of range means a signed integer that cannot be represented with 16 bits. In the case of divide by zero errors, go ahead and see what your assembly code returns in that case.

When item 5 is chosen, the program is exited.

The arithmetic code has to be written in assembly, but the other code can be written in C.

Explanation / Answer

#include using namespace std; void showChoices(); float add(float, float); float subtract(float, float); float multiply(float, float); float divide(float, float); int main() { float x, y; int choice; do { showChoices(); cin >> choice; switch (choice) { case 1: cout > x >> y; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote