#Script to prepare Electricity Bill
echo "Enter the name"
read name
echo "Enter the meter number"
read mno
echo "Enter the current month reading"
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 -a $unit -le 100 ]
then
charge=`expr $unit \* 1`
elif [ $unit -gt 100 -a $unit -le 300 ]
then
unit=`expr $unit - 100`
charge=`expr 100 + $unit`
elif [ $unit -gt 300 ]
then
unit=`expr $unit - 300`
charge=`expr $unit \* 2`
charge=`expr 300 + $charge`
fi
echo "EB Bill"
echo "---------"
echo "Consumer Name: $name"
echo "Meter Number : $mno"
echo "Units Consumed: `expr $cmr - $lmr`"
echo "Amount to be paid: $charge"
OUTPUT
Safi>sh EBbill.sh
Enter the name
ss
Enter the meter number
3340
Enter the current month reading
500
Enter the last month reading
100
EB Bill
---------
Consumer Name: ss
Meter Number : 3340
Units Consumed: 400
Amount to be paid: 500
echo "Enter the name"
read name
echo "Enter the meter number"
read mno
echo "Enter the current month reading"
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 -a $unit -le 100 ]
then
charge=`expr $unit \* 1`
elif [ $unit -gt 100 -a $unit -le 300 ]
then
unit=`expr $unit - 100`
charge=`expr 100 + $unit`
elif [ $unit -gt 300 ]
then
unit=`expr $unit - 300`
charge=`expr $unit \* 2`
charge=`expr 300 + $charge`
fi
echo "EB Bill"
echo "---------"
echo "Consumer Name: $name"
echo "Meter Number : $mno"
echo "Units Consumed: `expr $cmr - $lmr`"
echo "Amount to be paid: $charge"
OUTPUT
Safi>sh EBbill.sh
Enter the name
ss
Enter the meter number
3340
Enter the current month reading
500
Enter the last month reading
100
EB Bill
---------
Consumer Name: ss
Meter Number : 3340
Units Consumed: 400
Amount to be paid: 500
No comments:
Post a Comment