Lab 1: Getting acquainted with Perl Due Date: Saturday, 04/16/2011, 12:01 am. This lab is worth 10 points. You will learn how to write a program that can take user input and act accordingly. Your program will loop until it receives a 'quit' command. It should read "commands" from STDIN. The other commands that the program MUST implement are 'add' and 'subtract' (yes, I know, these are rather rudimentary, but this is only the first lab...). Anyway, after encountering an 'add' or 'subtract' command, the program should read two or more numbers from STDIN, and either add or subtract them, depending on which command was entered. You must also implement a 'quit' command. The user will continue to enter numbers until they decide to stop, at which point they will enter the string 'NONE'. You do not have to check to make sure what is entered in the number entry mode is a number- the only check you must do there is to see if they have entered NONE to finish the sequence of numbers. You do not have to worry about blank items being entered in any case- I will not be entering any illegal characters. Feel free to assume that there will be 10 or less numbers unless you plan to do the extra credit. So, in command mode, you should check for 'add', 'quit', and 'subtract', and execute the appropriate behavior. If the entry is something other than this, display an error message and return to command mode. In first number mode, you should allow anything to be entered, and assume that it is a number. In subsequent number entry mode, you should allow anything to be entered- if the thing that is entered is the string 'NONE', then stop allowing entries for this mode and display the result. Assume that anything else is a number, and then ask for the next number. An example sequence of your program's operation: Command> add Enter the first number: 1 Enter the second number: 5 Enter the third number: 8 Enter the fourth number: NONE The result is: 14 Command> subtract Enter the first number: 1 Enter the second number: 5 Enter the third number: NONE The result is: -4 Command> quit Additional requirements: 1. use a three different prompts depending on the circumstances- a. command mode (where you enter 'quit', 'add', etc): example prompt: "Enter a command:" b. first argument (the first number to add or subtract): example prompt: "Enter the first number:" c. second and following arguments (the subsequent numbers to add or subtract): example prompt: "Enter the next number or NONE to finish:" 2. be sure to also display a separate message for the answer- I would like to see something like: "The answer is: " 3. as mentioned above, the program must implement quit, add, and subtract, and must read all items from STDIN- these commands must be exactly as mentioned above: 'add','subtract','quit' 4. use a -w after your #! line 5. chmod 755 your lab before submitting it. the lab needs to be executable, so that I can easily script the grading. This isn't hard to do, so please do it (making the grader unhappy by not following directions is not good...) 6. if an invalid command is entered, print an error message, and then return to the command mode prompt 7. be sure to use the proper location of perl- /usr/local/bin/perl 8. be absolutely sure before you submit your program that it runs properly on the CSE systems, especially if you have written it somewhere else- you would be suprised what can work differently on our system than on windows... 9. you do NOT have to worry about checking the type of the input- assume that everything the user enters is already a number, with the obvious exception of checking for the string NONE when you are in the subsequent number entry mode. 10. use strict Extra Credit: 1. +1 implement 'multiply' and 'divide' 2. +1 implement 'q' as a substitute for quit (and 'a', 's', 'm', and 'd' for 'add', 'subtract', 'multiply' and 'divide') 3. +1 make the "answer is" prompt more interesting, perhaps including the operation being performed and the arguments, something like: "The answer for 9 + 10 is 19" 4. +2 keep track of all the math problems that the user has entered while the program has been running. Add a 'review' option in command mode that prints out all of the previous math problems, along with their results. 5. +5 implement the ability to print prompts for all numbers from "First" through "Two Hundred, Ninety-Ninth" without hard-coding them. Partial credit for good effort will be provided- just make sure it doesn't make the program NOT work for normal inputs from "First" through "Ninth". Other Notes: You should be able to do this assignement completely based on what we went over in class this week. However, arrays and hashes could make this much easier. You are always welcome to read ahead, but you will never HAVE to do so.