Lab 3

Lab assignment: Write a basic Calculator

In this week's lab you must write a C (not C++) program to simulate a simple integer calculator.  You will need to know simple input/output, declaring variables, if statements, arithmetic operations and a loop of some kind.

The execution of the finished program should look like what is shown below.  (User input is shown in bold, though in your program it will not be bold.)

Welcome to the calculator.

Your current value is 0

Options are:

  1. Add

  2. Subtract

  3. Multiply

  4. Divide

  9. Exit

Please enter an operation -> 1

Please enter the number to be added -> 4

Your current value is 4

Options are:

  1. Add

  2. Subtract

  3. Multiply

  4. Divide

  9. Exit

Please enter an operation -> 4

Please enter the number to be divided -> 3

Your current value is 1

Options are:

  1. Add

  2. Subtract

  3. Multiply

  4. Divide

  9. Exit

Please enter an operation -> 9

Your final value is 1.  Exiting program...

Notes:

Submission:

1. You should work with a partner for this (and all the remaining) lab(s).  Only one of you need to submit the program to Blackboard, though you should be certain that both of your names be present in a comment at the top of the .c or .cpp source file.

2. You should turn in to Blackboard by the end of the lab (8:50 for the 8-9 lab session, 9:50 for the 9-10 lab session).  I know it's tempting to keep working on it, but other classes come in, and it's not fair to the students who are limited to that particular time span if you go over.  Which isn't to say that you can't work on it later, to check your solution against the one I post for your own understanding.  But what you submit for a grade should be before the next hour begins.