Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i help with with this linux please! You will create a script file to perform bas

ID: 3688043 • Letter: I

Question

i help with with this linux please!

You will create a script file to perform basic calculations.

Create a script file called mycalc using vim.

The first line of your script file should force the use of the bash shell.

Your script file should be properly commented

The script file should perform the following operations: + and

The script should have two functions:

add and subtract

Each of the functions should accept two integer numbers as parameters

The functions should perform the desired calculation.

The script file should support two ways of functioning, no parameters or three parameters.

If three parameters are provided, the second parameter must be + or :

The First and Third parameters must be numbers.

The user can enter integer numbers only.

The result should be displayed on the screen and the program exit.

The example below shows how plus would work. Do similar for -

Example:

mycalc 12 + 3

The sum of 12 plus 3 equals 15

If no parameters are provided the script should do the following:

A menu should be provided allowing the user to exit or Do a calculation. Allow upper or lower case. See Menu 1 below.

If C is selected the screen should clear and the user should be prompted to enter a number. See Menu 2 below.

If a number is entered the screen should clear and a new menu should be displayed. See Menu 3 below.

If + or - is entered the screen should clear and the user should be prompted to enter a number. See Menu 2 below.

If a number was entered the result should be shown on the screen

After three seconds the screen should clear and Menu 1 should be displayed again.

Error checking should be done to make sure of the following:

Either no parameters or three parameters are entered.

If three parameters are entered then the second parameter must be one of the following + -

Any invalid choices should be flagged in the menu system

You don’t need to check if the input numbers are integers

Menu 1                           Menu 2                                                                        Menu3

C) Calculation                 Please enter an integer number or X to exit:            +) Add

X) Exit                                                                                                            - ) Subtract

X) Exit

Explanation / Answer

#!/bin/bash
add(){
   echo "The sum of $1 and $2 equals `expr $1 + $2`";
}
subtract(){
   echo "The sub of $1 and $2 equals `expr $1 - $2`";
}
mycalc(){
case $2 in
+) add $1 $3
   ;;
-) subtract $1 $3
   ;;

esac
}
if [ $1 eq
mycalc $1 $2 $3