0% found this document useful (0 votes)
96 views1 page

Week#4 ShellProgramming

This document outlines 5 exercises for a shell programming assignment. Exercise 1 involves writing a shell script for a basic calculator that can add, subtract, multiply and divide two numbers. Exercise 2 is to write a shell script to reverse the rows and columns of a matrix either interactively or via command line arguments. Exercise 3 is an employee pay calculation script using if/else statements. Exercise 4 is a vehicle rental cost calculator using if/else statements. Exercise 5 is to write a script to calculate the factorial of a given number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views1 page

Week#4 ShellProgramming

This document outlines 5 exercises for a shell programming assignment. Exercise 1 involves writing a shell script for a basic calculator that can add, subtract, multiply and divide two numbers. Exercise 2 is to write a shell script to reverse the rows and columns of a matrix either interactively or via command line arguments. Exercise 3 is an employee pay calculation script using if/else statements. Exercise 4 is a vehicle rental cost calculator using if/else statements. Exercise 5 is to write a script to calculate the factorial of a given number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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