Due Tuesday, August 4th, at the start of class.
In this assignment, you'll write a Perl script that functions as a simple calculator. This script should employ the Perl exception handling capabilities to handle illegal operations (such as division by zero, etc).
Your script should prompt the user, and then read a math operation from the standard input stream. At a minimum, the program should handle input of the form: <number><operator><number>, where <operator > is "*", "/", "+", or "-".
Your script should then process this operation, compute the result, and print it. Here's a sample of my solution running:
perl ./homework-13.pl Enter operation (q to quit): 7/8 7/8 = 0.875 Enter operation (q to quit): 3*4 3*4 = 12 Enter operation (q to quit): 0/0 0/0: Illegal division by zero
Optional. If you wish, you can make your script handle more generic forms of input:
Enter operation (q to quit): 3+5*5 3+5*5 = 28 Enter operation (q to quit): (3+5)*5 (3+5)*5 = 40 Enter operation (q to quit): q
Do the work yourself, consulting reasonable reference materials as needed; any reference material that gives you a complete or nearly complete solution to this problem or a similar one is not OK to use. Asking the instructors for help is OK, asking other students for help is not.
A printout of your script on a single sheet of paper. At the top of the printout, please include “CS 368 Summer 2009”, your name, and “Homework 13, August 4, 2009”. Identifying your work is important, or you may not receive appropriate credit.