Code In Tech - The Ultimate World of Computer Technology

Monday, 4 June 2012

Shell script to read name and price of article and calculate net price with discount as follows.>If price less than 100 then 10% discount If price >= 100 then 20% discount

SOURCE CODE:

echo “Enter the article’s name:“
read name
echo “Enter the  price:”
read p
if [ $p –lt 100 ]
then
     t=`expr $p \* 10`
     r=`expr $t / 100`
     n=` expr $p - $r`
else
    
t=`expr $p \* 20`
     r=`expr $t / 100`
     n=`expr $p - $r`
fi
echo “net Price:” $n

OUTPUT:

Enter the article’s name:
Drawing book
Enter the  price:
125
Net price:100

No comments :

Post a Comment