III - Cs - Linux - Record
III - Cs - Linux - Record
Output:
Enter the number
7
Prime number
[redhat35@localhost Rhel5]$ sh prime.sh
Enter the number
4
Not Prime
2 . Find the biggest of given two numbers
Output:
OUTPUT::
ENTER THE NUMBER
5
5 is odd
4. Fibonacci Series
OUTPUT:
ENTER THE NO
5
The Fibonacci Series Is
0
1
2
3
5. Electric Bill For Domestic Consumers.
clear
echo
echo '\tCalculate Electricity Charge'
echo
echo Enter the Name
read name
echo Enter the Meter number
read mno
echo Enter the current month rea ding
read cmr
echo Enter the last month reading
read lmr
unit=$(expr $cmr - $lmr)
if [ $unit -eq 0 ]
then
charge=40
elif [ $unit -gt 0 ] && [ $unit -le 100 ]
then
charge=$(expr $unit \* 1)
elif [ $unit -gt 100 ] && [ $unit -le 300 ]
then
charge=$(expr 100 \* 1 + $unit - 100)
elif [ $unit -gt 300 ] && [ $unit -le 500 ]
then
charge=$(expr $unit \* 1 + 200 \* 2 + $unit - 300)
elif [ $unit -gt 500 ]
then
charge=$(expr 1400 + $unit - 400)
fi
echo
echo '\tElectricity Billing'
echo
echo "Name : $name"
echo "Meter Number : $mno"
echo "Current Month reading : $cmr"
echo "Last Month reading : $lmr"
echo "Unit : $unit"
echo "Charge : $charge"
echo
output:
-
Calculate Electricity Charge
-
Enter the Name
SATHEESH
Enter the Meter number
E1234
Enter the current month reading
456
Enter the last month reading
123
-
Electricity Billing
-
Name : SATHEESH
Meter Number : E1234
Current Month reading : 456
Last Month reading : 123
Unit : 333
Charge : 766
6. Students Details
clear
echo
echo '\tStudent Mark List'
echo
echo Enter the Student name
read name
echo Enter the Register number
read rno
echo Enter the Mark1
read m1
echo Enter the Mark2
read m2
echo Enter the Mark3
read m3
echo Enter the Mark4
read m4
echo Enter the Mark5
read m5
tot=$(expr $m1 + $m2 + $m3 + $m4 + $m5)
avg=$(expr $tot / 5)
echo
echo '\tStudent Mark List'
echo
echo "Student Name : $name"
echo "Register Number : $rno"
echo "Mark1 : $m1"
echo "Mark2 : $m2"
echo "Mark3 : $m3"
echo "Mark4 : $m4"
echo "Mark5 : $m5"
echo "Total : $tot"
echo "Average : $avg"
if [ $m1 –ge 50 ] && [ $m2 -ge 50 ] && [ $m3 -ge 50 ] && [ $m4 –ge 50 ] && [ $m5 -ge 50 ]
then
echo "Result : Pass"
if [ $avg -ge 90 ]
then
echo "Grade : S"
elif [ $avg -ge 80 ]
then
echo "Grade : A"
elif [ $avg -ge 70 ]
then
echo "Grade : B"
elif [ $avg -ge 60 ]
then
echo "Grade : C"
elif [ $avg -ge 50 ]
then
echo "Grade : D"
elif [ $avg -ge 35 ]
then
echo "Grade : E"
fi
else
echo "Result : Fail"
fi
echo
OUTPUT
output:
clear
echo
read str
len=$(expr length $str)
count=0
while [ $len -gt 0 ]
do
ch=$(echo $str | cut -c $len)
case $ch in
[aeiouAEIOU] )
count=$(($count + 1))
echo “The vowels are $ch”
;;
esac
len=$(( $len - 1 ))
done
echo “Total No of vowels are $count”
Output
Enter the word
English
vowels are
i
e
Total no of vowels:2
9. Ascending order descending order
clear
i="y"
echo "Enter name of database "
read db
while [ $i = "y" ]
do
clear
echo "1.View the Data Base "
echo "2.View Specific Records "
echo "3.Add Records "
echo "4.Delete Records "
echo "5.Exit "
echo "Enter your choice "
read ch
case $ch in
1)cat $db;;
2)echo "Enter id "
read id
grep -i "$id" $db;;
3)echo “enter name”
read name
echo "Enter qualification"
read tid
echo "Enter address:"
read tnm
echo "Enter fathername "
read des
echo "Enter Hobbies”
read hobbies
echo "$tid $tnm $des $college">>$db;;
4)echo "Enter Id"
read id
# set -a
# sed '/$id/d' $db>dbs1
grep -v "$id" $db >dbs1
echo "Record is deleted"
cat dbs1;;
5)exit;;
*)echo "Invalid choice ";;
esac
echo "Do u want to continue ?"
read i
if [ $i != "y" ]
then
exit
fi
done
Output:
Enter name of the database: Anitha
1.view the database
2. iew specific Records
3.Add records
4.Delete Records
5.Exit
Enter your choice:3
Enter the id :4
Enter the name: Anitha
Enter qualification : B.Sc computer science
Enter address : Madurai
Enter father name : Jayakumar
Enter hobbies : Listening songs
Do you want to continue
y
Enter your choice :2
enter id :4
Name :anitha
qualification:B.sc computer science
address :Madurai
fathername :jayakumar
hobbies :listening songs
Do you want to continue Y
Enter your choice :4
enter id :4
Deleted successfully
Do you want to continue
y
Enter your choice :1
anu anitha bovunya harini reethu
Do you want to continue
y
Enter your choice :5
Exit