|
Go4Expert Member
|
|
|
14Jul2009,01:46
|
|
|
|
Write a program to simulate hand-held electronic calculator. Your program should execute as follows:
- Step 1: display a prompt and wait for the user to enter an instruction code (a single character):
‘+’ for addition
‘-‘ for subtraction
‘*’ for multiplication
‘/’ for division
‘p’ for power
‘c’ to clear the current accumulator
‘s’ for square root
‘l’ for log
‘n’ for ln
‘q’ for quit - Step 2: (if needed) display a prompt and wait for the user to enter a type float number (which we will call left-operand)
- Step 3: (if needed) display a prompt and wait for the user to enter a type float number (which we will call right-operand)
- Step 4: display the accumulated result at any point during processing and repeat steps 1 through 3 using a GOTO statement (no loops in this assignment).
Use a separate function enter_code to prompt the user for instruction code and to ensure that a valid code is entered. Also, use a separate function enter_operand for the entry of the left-operand and the right-operand. Finally, use another function compute to perform the indicated operation. (unless q was entered).
|