PUTTY REQUIRED

Please write a BASH script that does that adds, subtracts, multiplies and divides two integers

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Users MUST enter two operands and an operator (no need to ensure that what they are entering is in that format…assume that it is).

The format of the inputs should be operand-space-operator-space-operand

examples 
1 + 1
2 * 2
5 – 3
6 / 4

Requirements…

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

1. if no arguments are entered on the command line then we will assume that the inputs will be entered interactively

2. if 3 arguments are entered on the command line then we will go ahead and provide the answer

3. if 1 or 2 or more than 3 arguments are entered on the command line you should echo an error message explain what must be entered and immediately exit.

**** PLEASE UNDERSTAND that “*” is a reserved character in BASH and cannot be casually used as an input variable without bad things happening, but I would still like to use the “*” because it is common syntax for multiplication. I you cannot resolve this please go ahead and use “x” or “X” (both MUST work). I will, however, give 5 extra credit points to those that can make “*” work***

4. In the case of division you MUST check that the divisor is not 0 (you can’t divide by 0)

5. In case of division you must provide the result of the division operator AND the remainder (modulo)

6. If 3 arguments are not entered on the command line then your script should first ask “would you like to do some math?”.

7. if the user answers “yes” then your script should ask you to enter, via 3 separate requests, the 1st operand, the operator and then the 2nd operand.

8. if the user answers “no” then the script should give the user a polite message welcoming them back to do some math anytime and telling them when the script finished (by using the “date” command)

9. A function must be declared that actually performs the math…so you will definitely be calling a function within this script

10. This function will be called only once if the 3 inputs appear on the command line. The script should exit immediately afterward.

11. The function will be continuously called until you reply “no” to the question “would you like to do some math?” (maybe a while loop)

12. A case statement is likely the best way to implement the various mathematical operations in the case statement but there must be a default case where a bogus operator is entered (not +, -, / or *). This default case should give the user an error message,

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER