0% found this document useful (0 votes)
321 views

Lab Manual Answers Part 2 - Shell Programming

The document provides 19 scenarios for shell scripting programs. The scenarios cover a variety of tasks including accepting user input for calculations, conditional logic, looping, and output formatting. The shell scripts are to be saved with descriptive names and provide appropriate output for each scenario. The scenarios include programs for calculating course marks, weight conversion, salary calculations, rental costs, ticket prices, and more. Conditionals are introduced to check for passing grades or laundry service types. Loops are used to input multiple records and perform calculations across them.

Uploaded by

Khan Sahib
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
321 views

Lab Manual Answers Part 2 - Shell Programming

The document provides 19 scenarios for shell scripting programs. The scenarios cover a variety of tasks including accepting user input for calculations, conditional logic, looping, and output formatting. The shell scripts are to be saved with descriptive names and provide appropriate output for each scenario. The scenarios include programs for calculating course marks, weight conversion, salary calculations, rental costs, ticket prices, and more. Conditionals are introduced to check for passing grades or laundry service types. Loops are used to input multiple records and perform calculations across them.

Uploaded by

Khan Sahib
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lab Manual

SHELL PROGRAMMING
Scenario #7
Your Math Teacher wants you to create a simple application. In the program, it will accept the quiz
mark, assignment mark, practical mark, and class activity mark. Then, it computes the total coursework
mark by adding the quiz, assignment, practical, and class activity marks. Display an appropriate output.
Save your shell script as coursework.sh.
Output

Scenario #8
Your Science Teacher wants you to create a simple application. In the program, it will accept the weight
in kilogram, and will convert it into pound. One kilogram is equivalent to 2.205 pounds. Display an
appropriate output. Save you shell script as weight.sh.
Output

Scenario #9
Oman Manpower Services tasks you to create an application. In the simple program, it will allow the
user to enter the employee name, employee position, monthly basic salary, and number of days of
overtime. The overtime pay is computed as daily rate times numbers of days overtime times 20 %. To
compute the daily rate, divide the monthly basic salary by 22. Display an appropriate output. Save your
shell script as salary.sh.
Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 14


Lab Manual

Scenario #10
XYZ Car Rentals wants you to create a simple application. The program will enter customer name,
customer address, customer mobile number, car type to reserve, rental rate per day, and number of days
to use the car. Compute the total cost of rental by multiplying the rate per day by the number of days to
use the car. Display the appropriate output. Save your shell script as xyz.sh.
Output

Scenario #11
Sohar Park Entertainment Inc. wants you to create a simple application. The program will enter visitor
name, visitor address, visitor mobile number, number of tickets for adults, and number of tickets for
children. Price for each ticket for adult is 3 rials while for children is 2 rials. Compute the total cost of
tickets. Display the appropriate output. Save your shell script as soharpark.sh.
Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 15


Lab Manual

USING CONDITIONAL STATEMENTS


Scenario #12
Your OS Teacher wants you to create a simple application. In the program, it will accept the quiz mark,
assignment mark, practical mark, class activity mark, midterm exam, and final exam. Then, it computes
the total mark by adding the quiz, assignment, practical, class activity, midterm exam and final exam
marks. If the total mark is greater than equal to 75, then display the remark “Passed”, otherwise display
the remark “Failed”. Display an appropriate output. Save your shell script as mark.sh.
Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 16


Lab Manual

Scenario #13
Al-Ghaseel Laundry Services wants you to revise the application you have done before. This time, the
application will allow the user to enter the customer name, weight in kilo of the laundry, and type of
laundry service. The options for laundry service will be “normalwash”, “dryclean”, and “ironing”. If
the laundry service selected is “normalwash”, the price of laundry service per kilo is 5 rials. If the
laundry service selected is “dryclean”, the price of laundry service per kilo is 7.50 rials. If the laundry
service selected is “ironing”, the price of laundry service per kilo is 10 rials. Compute the total cost of
laundry service by multiplying the weight in kilo of the laundry by the price of laundry service per kilo.
Display an appropriate output. Save your shell script as newlaundry.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 17


Lab Manual

Scenario #14
Sohar Manpower Services tasks you to create an application. In the simple program, it will allow the
user to enter the employee name, employee position, type of employees, monthly basic salary, and
number of days of overtime. The options of type of employees will be “permanent”, “probationary”
and “casual”. If the type of employee is “permanent”, the overtime rate is 30%. If the type of employee
is “probationary”, the overtime rate is 25%. If the type of employee is “casual”, the overtime rate is
20%. The overtime pay is computed as daily rate times the numbers of days overtime times the overtime
rate. To compute the daily rate, divide the monthly basic salary by 22. Display an appropriate output.
Save your shell script as employee.sh.
Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 18


Lab Manual

USING LOOPING STATEMENTS


Scenario #15
Your Food Fastfood Inc. wants you to create a simple application. The program will enter records of
five (5) buyers which include buyer name, buyer address, meal type, and meal price. Based on the
inputted records, the program can determine the buyer who has the lowest meal price and highest meal
price. Also, compute the average meal price. Display the appropriate output. Save your shell script as
yourfood.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 19


Lab Manual

Scenario #16
Splash Apparels Inc. wants you to create a simple application. The program will enter records of five
(5) shoppers which include shopper name, shopper address, clothes type, and clothes price. Based on
the inputted records, the program can determine the shopper who has the lowest clothes price and
highest clothes price. Also, compute the average clothes price. Display the appropriate output. Save
your shell script as yourfood.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 20


Lab Manual

Scenario #17
Royal Opera Oman Inc. wants you to create a simple application. First, the program will ask the user
to enter the number of guests. Then, the program will ask the user to input the following: guest name,
guest address, and ticket type. Ticket type can be “adult”, “child”, or “student”. Based on the inputted
records, the program will count the total number of “adult” tickets, “child” tickets, and “student” tickets.
Save your shell script as royalopera.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 21


Lab Manual

Scenario #18
You are required to write a shell script that will ask the user to input the name of bank, and the number
of loans. Based on the number of loans inputted, the user also inputs loan amount. For example, if the
number of loans is four (4), then the user will enter four (4) loan amounts. Based on the loan amounts
entered, the program should be able to count the number of long term loans, the number of medium
term loans, and the number of short term loans.
The classification of loan amount is based on the table below:
Loan Amount > = 10000 Long
Loan Amount > = 5000 and Donation Amount < = 9999 Medium
Loan Amount < 5000 Short

Calculate the total loan amounts. Display the number of long term loans, number of medium term loans,
and number of short term loans. Save your shell script as loan.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 22


Lab Manual

Scenario #19
Your IT Teacher wants you to create a simple application. In the program, it will accept the coursework,
midterm exam, and final exam marks. Then, it computes the total final mark by adding the course work,
midterm exam, and final exam marks. Based on the computed total final mark, a letter grade will be
display. The letter grade will be based on the table below:
Total Final Mark Letter Grade
90 – 100 A
80 – 89 B
70 – 79 C
60 – 69 D
50 - 59 E
Below 50 F
Display the appropriate output. Save your shell script as lettergrade.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 23


Lab Manual

Scenario #20
TAGLIF-Oman, one of the largest BoPP film producers worldwide for food packaging and labeling,
requested you to develop a shell script that computes the salary of their employees. The user is required
to enter the employee name, employee id, job title, and number of years’ experience. For job title,
options will be Engineer, Supervisor, and Technician. The basic salary is based on the job title and
number of years’ experience, as given below:

No of Yrs Exp Engineer Supervisor Technician


1 to 5 years 1000 800 600
6 to 10 years 1250 1000 850
More than 10 years 1500 1200 1000
Display the basic salary of the inputted record. Display the appropriate output. Save your shell script
as jobtitle.sh.

Output

Introduction to Operating System (ITSE102) AY: 2020 -2021, Semester 1 Page 24

You might also like