Lab Manual Answers Part 2 - Shell Programming
Lab Manual Answers Part 2 - Shell Programming
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
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
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
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
Output
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
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
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
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
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:
Output