Shell Script to read price of an article and calculate discount

in Categories Shell Math last updated April 4, 2008
#!/bin/bash
# Script to read price of an article. If the price is less than 100
# then display "No discount" else give a discount of 10%. Display
# the price of article after discount
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
echo -n "Enter price of an article : "
read price
 
if [ $price -lt 100 ]
then
   echo "No discount "
   d=0 # 0 means no discount
else
   echo "10% discount "	
   d=$(( $price  * 10 / 100 )) # 10% discount
fi
# how much user need to pay? after discount
pay=$(( $price - $d ))
echo "You need to pay INR. $pay"