User Input | Operation |
---|---|
Your program will NOT support operator precedence.
You should initialize the value of the expression to 0.
Operations will be performed in the order they are entered.
After each operation is performed, the current value of the expression
will be displayed (show 2 decimal places). Your program should prompt the
user for input as
needed. Command input should be validated. When an invalid command is
entered, an error message should be display that includes the invalid
command character and the user asked for another input.
You will write a C function for each operation. That function will take the the current value of the expression as a parameter, prompt for additional input (if needed), perform the operation and return the new value of the expression to the caller. The function should also print a message indicating the operation being performed and the value of the operands. For example, the addition function might print: Adding 6 to 19. The square root, absolute value and exponentation operations will be performed by using the appropriate math library func tion.
% script % cc project3.c -lm % a.out < /afs/umbc.edu/users/d/e/dennis/pub/cs104/proj3/proj3.dat % exit % mv typescript project3.out If you are in section 103, submit your project with the command % submit cs104-103 proj3 project3.c project3.out If you are in section 301, submit your project with the command % submit cs104-301 proj3 project3.c project3.out
retriever[102] a.out starting total is 0.00 Input operation: + Input value: 10 adding 10.00 to 0.00 subtotal = 10.00 Input operation: - Input value: 3 subtracting 3.00 from 10.00 subtotal = 7.00 Input operation: / Input value: 2 dividing 7.00 by 2.00 subtotal = 3.50 Input operation: * Input value: 5 multiplying 3.50 by 5.00 subtotal = 17.50 Input operation: k invalid command: k subtotal = 17.50 Input operation: E Exiting subtotal = 17.50 total is 17.50 retriever[103]