Question
Can I have this in linux shell script please and thank you! Submission Demonstrate your script execution on your laptop to the professor during your
Can I have this in linux shell script please and thank you!
Submission
Demonstrate your script execution on your laptop to the professor during your scheduled lab periods and submit the completed lab file on BlackBoard before the due date.
Procedure
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.
On the top of the script file, there should be a section of comments that contains the Assignment number, your name, student number, lab section number, name of the script file, the date, and a description of what the script file does.
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 dont need to check if the input numbers are integers
Menu 1 | Menu 2 | Menu3 |
C) Calculation X) Exit | Please enter an integer number or X to exit: | +) Add - ) Subtract X) Exit |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started