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.
Please enter a single expression of the format (number operator number)
Numbers should be integers, operator should be one of (+,-,*,/)
Be sure to leave a space between the numbers and the operator.
Please enter your expression -> 9 * 7
The result of your expression is 63.
Stage 1 (1 point):
Write an input statement to read in the expression into two int variables and a char, then echo (print) those 3 variables back to the screen.
Just a heads up, operator is a reserved name, so don't use it as a variable name.
Stage 2 (1 point):
Employ if statements based on the character operator to perform the calculation. Then print the result to the screen, as shown in the example.
Stage 3 (Extra Credit) (1 point):
Add one more operation to your calculator: exponentiation, that is the first number to the power of the second number. The operator for exponentiation should be ^, and you should change the prompt to reflect this. To give you an example, 2 ^ 5 should return 32. You must do this by setting up a loop to perform the correct number of multiplications. (You may not use the pow method, in case you know what that is.)
Keep in mind that this is a team effort so you should agree with your partner on what you are going to do before you start typing. The partner who is typing is the "driver" and the partner watching is the "navigator." Be sure to switch roles every 10 to 15 minutes, to foster a deep understanding of the code for both partners. The navigator should be watching for syntax errors and verifying the correctness of the code you're writing.
It will speed things up for you if you keep a window open for editing and have a separate window open for compiling and running your program. Remember that windows are resizeable!
You should work with a partner for a grade. Only one submission per group is necessary, but be sure to include your name if you work alone, or both people's names if you worked with a partner.
You should submit the lab at the end of the lab session, by 50 minutes after the hour. If you do not finish the lab, you may submit the lab by noon on Friday for a 1 point penalty. (1:50 for 1 pm lab, 2:50 for 2 pm lab, 3:50 for 3 pm lab and 4:50 for the 4 pm lab) .