Wednesday, January 14, 2009

Program in UNIX to determine whether the seller has made profit or incurred loss

If cost price and selling price of am item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit was made or loss incurred.

echo "Enter the cost price"
read cp
echo "Enter the selling price"
read sp

if [ $sp -gt $cp ]
then
profit=`expr $sp - $cp`
echo "Profit made is $profit"
else
loss=`expr $cp - $sp`
echo "Loss is $loss"
fi

Program in UNIX to determine whether the seller has made profit or incurred lossSocialTwist Tell-a-Friend

0 comments: