Lab_9

docx

School

Algonquin College *

*We aren’t endorsed by this school

Course

8116

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Uploaded by EarlRam3624

Report
Lab Assignment 9 CST8102 Operating Systems Fundamentals with Linux Linux Shell Scripting III Submission Demonstrate your script execution to your lab professor during your scheduled lab period and submit your completed lab on Brightspace before or on the due date of the assignment. Labs that have not been demoed will receive a score of 0. Procedure You will create a script file to perform basic calculations. 1. Create a script file called mycalc.sh using vim . 2. The first line of your script file should force the use of the bash shell. 3. At the header of the script file there should be a section of comments that contains the following a. assignment number b. your name and student number c. lab section number d. name of the script file e. the date f. a description of what the script file does 4. It is recommended that your script file is commented throughout the script. 5. The script file should perform the following operations: ' +' and ' -' (addition and subtraction). 6. The script must have two functions: a. Each named add and subtract b. Each of the functions must accept two integer numbers as parameters c. The functions must perform the desired algebraic operation 2. The script file should support two modes of operation, either with no parameters or with three parameters. If the incorrect number of parameters is provided, the script should output an error and quit. a. 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 demonstrates how the plus operation should work. Do a similar operation for '-' Example: ./mycalc 12 + 3 The sum of 12 plus 3 equals 15 ©Algonquin College 30 November 2023 1
Lab Assignment 9 CST8102 Operating Systems Fundamentals with Linux If no parameters are provided the script should do the following: A menu should be provided allowing the user to either Exit or Do a Calculation . Allow upper or lower case menu selections. See Menu 1 below. Menu 1 C) Calculation X) Exit If the 'C' menu option is selected from Menu 1, the screen should clear and the user should be prompted to enter a number. See Menu 2 below. You don’t need to check if the input numbers are integers Menu 2 Please enter an integer number or X to exit: If a number is entered into Menu 2, the screen should clear and a new menu should be displayed. See Menu 3 below. Menu3 +) Add - ) Subtract X) Exit If + or - is entered the screen should clear and the user should be prompted to enter a second number. See Menu 2 above. If a second number was entered the calculated result should be displayed on the screen. After three seconds the screen should clear and Menu 1 should be displayed again. c. 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 + or -. Any invalid choices in the menu system should be recognized/identified, and the user should be presented the menu item again. You don’t need to check if the input numbers are integers. ©Algonquin College 30 November 2023 2
Lab Assignment 9 CST8102 Operating Systems Fundamentals with Linux 8. Make a copy of the file with a .txt extension. Upload this file to Brightspace. Do not zip the file. Marking Guide: Criteria 3 Points 2 Points 1 Point 0 Points Point s Output Matches output exactly as stated in the lab. Very close to what is stated in the lab Has output, but is missing or outputting incorrectly No output /3 Errors None Minor errors but still runs Major errors but still runs Does not run /3 Comments Code is fully documented including identificatio n comments Code has some documentatio n including identification comments Only identification comments are included No comments /3 Control Structures Decision structures and/or loops work and are as taught Decision structures and/or loops work and but not as taught Decision structures and /or loops are present but some do not work Decision structures and /or loops are present but do not work /3 ©Algonquin College 30 November 2023 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Lab Assignment 9 CST8102 Operating Systems Fundamentals with Linux Criteria 3 Points 2 Points 1 Point 0 Points Point s Lab specific skills such as arithmetic, loops and parameters Lab specific skills work and are done as taught Lab specific skills work and are not done as taught Some Lab specific skills work Lab specific skills does not work at all /3 Student is able to explain what their code is doing No hesitation and obviously knows what the code is doing Minor difficulty explaining their code or is unsure of some aspect Major difficulty explaining their code or barely understands what some of the structures do. Cannot explain. /3 Following the specification(s) as listed in the lab assignment Perfect Minor deviation and/or may be missing minor items Major deviations and/or pieces missing Completely incorrect /3 ©Algonquin College 30 November 2023 4