LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   KSH Scripting case statement..... (https://www.linuxquestions.org/questions/programming-9/ksh-scripting-case-statement-264879/)

']['HeBroken 12-10-2004 10:31 AM

KSH Scripting case statement.....
 
ok im using aix unix v4


im having bit of a problem. when i run the code it goes over fine but when it come to the math it just sux.... it doubles the price after you put the code in. can anyne help me thanx...

Code:

#! /bin/ksh
# +--------------------+
# | BOBBY D ESTRADA    |
# +--------------------+




print -n "\n Please Enter Price: "
read price
print -n "\n Please Enter Coupon Code: "
read code


case $code in
        H|h)
total=`print "scale=3; $price / .50"|bc`
;;
        F|f)
total=`print "scale=3; $price / .40"|bc`
;;
        T|t)
total=`print "scale=3; $price / .33"|bc`
;;
        Q|q)
total=`print "scale=3; $price / .25"|bc`
;;
        *)

print "\nNO DISCOUNT"
total=$price
;;
esac

print "\nPrice: $price\nCode: $code\nTotal:$total "

thanx in advance

Cedrik 12-10-2004 10:38 AM

There are not errors in code, bur maybe math confusion ?

x / .25 = x * 4


All times are GMT -5. The time now is 11:01 AM.