Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Week # 4 Assignment

Shell Programming
Exercise 1
Write a shell script (small calculator) that adds, subtracts, multiplies and divides the two given
numbers. There are two division options: one returns the quotient and the other remainder. The
script requires three arguments: the operation to be used and the two integers. The operation are
specified by options:
Add -a
Subtract-s
Multiply -m
Quotient -c
Remainder -r
Use the if and case structures.

Exercise 2
Write a shell script to reverse the rows and columns of a matrix.
a) Interactively.
b) By command line arguments.

Exercise 3
Employee Pay Calculation
If basic > 30000 then
hra is 5% of basic,
da is 5% of basic,
tax is 10% of basic,
else if basic > 20000 then
hra is 4% of basic,
da is 3% of basic,
tax is 8% of basic,
else hra is 3% of basic,
da is 2% of basic, tax is 5% of basic,
netpay=basic+hra+da-tax

Exercise 4
To find Rental Options
If vehicle = "car" then
Print "Rental is Rs. 20/km"
else if vehicle = "van" then
Print "Rental is Rs. 10/km"
else if vehicle = "jeep" the
Print "Rental is Rs. 5/km"
else if vehicle = "bicycle" then
Print "Rental is Rs. 0.2/km"

Exercise 5
To find the Factorial Value of the input number.

You might also like