lassie% a.out Enter an expression ending with '=' 1.2 + 2.0 + 3.1 * 4 - 5 + 6 * 7 = Answer = 183.4 lassie%You do not have to worry about numbers that are too big or too small (overflow and underflow errors) and you do not have to handle input in scientific notation (e.g., 314.159e-2). For simplicity, assume that all numbers begin with a digit (i.e., .1234 is not allowed, but 0.1234 is). Also, your calculator should evaluate the operators left to right without regard to operator precedence. For example:
lassie% a.out Enter an expression ending with '=' 3 + 4 * 5 = Answer = 35 lassie%However, your calculator should give rudimentary error messages:
lassie% a.out Enter an expression ending with '=' 3 4 + 7 = Error: Unknown operator: 4 lassie% a.out Enter an expression ending with '=' 34a9 + 7 = Error: Unknown operator: a lassie% a.out Enter an expression ending with '=' abd + bde = Error: Bad Syntax, pos = 0, abd + bde =You absolutely must spend some time early to think about this project before writing any code. A good design will make your project easy to implement and to debug. A bad design will result in messy, error-prone and undebuggable code.
lassie% cat test4 1.1 * 3.4 + 7.92 - 4.8 /2+7+56 / 3 = lassie%To run your program on the test file, use the UNIX redirection command:
lassie% a.out <test4 Enter an expression ending with '=' Answer = 22.1433 lassie%Use the script command to save a copy of your output. To do this, remove any old typescript files you have, type script, run your program to duplicate the sample runs then type exit at the prompt. Use an editor (e.g., emacs) to check that the file actually contains your output before you turn it in. When you have successfully created the typescript file, and have deleted all the blank lines at the end of your program, submit your program using the submit201 command that you copied for Project~1. To submit both your project and the typescript file, issue the command:
% submit201 proj4.c typescriptPlease check your own mail to see if you have submitted the correct files.
Richard Chang, email@example.com