Write a shell script to calculate profit or loss.
echo "input nthe cost price of an
item"
read cop
echo "input the selling price of
the item"
read sop
if test $cop -eq $sop
then
echo "no profit or no gain"
fi
if test $cop -gt $sop
then
s=`echo $cop - $sop |bc`
echo " u obtained loss of
rs:$s"
else
s=`echo $sop - $cop |bc`
echo "u obtained profit of
rs:$s"
fi
Output:
[root@localhost shell_script]# bash
profitloss.sh
input nthe cost price of an item
100
input the selling price of the item
120
u obtained profit of rs:20
No comments:
Post a Comment