0% found this document useful (0 votes)
8 views8 pages

OS Lab Tasks

Uploaded by

ateeb.shadow420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views8 pages

OS Lab Tasks

Uploaded by

ateeb.shadow420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Operating System

Lab Manual

Topic: Shell Programming


Deadline : 12th November 2024 at 12pm
Session: Fall 2024
School of Systems and Technology
UMT Lahore Pakistan
Name : Muhammad Moiz
Roll No. : F2022065169
Question 1:
Write a Bash script for a cafeteria menu that allows users to order items and calculates their total
bill. The menu should have the following options:
1. Order Coffee - Costs $5 each.
2. Order Tea - Costs $3 each.
3. Order Sandwich - Costs $7 each.
4. Order Cake - Costs $4 each.
5. Exit - Exits the program.
The script should:
 Prompt the user to choose an option from the menu.
 If the user chooses Coffee, Tea, Sandwich, or Cake, ask them for the quantity they want
to order.
 Calculate the total bill based on the quantity and display it.
 If the user chooses Exit, display a farewell message and end the program.
 If the user enters an invalid option, show an error message.

Code:
Commands:

Output:

Exit:

Error Handling:
Question 2:

Question: Write a Bash script for a basic banking application that allows users to check their
account balance and perform withdrawals. The script should have the following functionality:

1. Prompt the user to enter their current account balance (a number).


2. Provide a menu of actions:
o 1: Check Balance
o 2: Withdraw Funds
o 3: Exit
3. If the user chooses to check their balance, display the current balance.
4. If the user chooses to withdraw funds:
o Prompt for the withdrawal amount.
o If the withdrawal amount is less than or equal to the balance, deduct the amount
and display the new balance.
o If the withdrawal amount is greater than the balance, display an error message
stating insufficient funds.
5. If the user chooses to exit, end the program.
6. Handle invalid options in the menu.

Code:
Commands:

Output:

1-Check Balance :
2-Withdraw:

3-Error Handling :
Question 3:
Question: Write a Bash script for a simple grading system based on a student's score. The script
should determine the letter grade according to the following criteria:

1. If the score is 90 or above, the grade is A.


2. If the score is 80 to 89, the grade is B.
3. If the score is 70 to 79, the grade is C.
4. If the score is 60 to 69, the grade is D.
5. If the score is below 60, the grade is F.
Code:

Commands:

Output-1:

Output-2:
Page 1 of 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy