LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices

Reply
 
Search this Thread
Old 12-10-2004, 10:27 AM   #1
']['HeBroken
Member
 
Registered: Oct 2004
Posts: 35

Rep: Reputation: 15
Case Statement With Aix Ksh Scripting


ok here is my problem i just wrote this program its gonna take a price and a discount code and give a quick discount to it but when i run the program it will double the price from it original when it supposed to taking it off.... well hereis the code if anyone can tell me where i went wrong that would be a big help thank you very much


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 "
 
Old 12-11-2004, 10:54 AM   #2
zorba4
Member
 
Registered: Feb 2004
Location: Paris
Posts: 398

Rep: Reputation: 31
Just try it with your pocket calculator : 2/0.5=4.
If you want to take off 50%, it should be 2*0.5 instead of 2/0.5 !
Am I not right ?
 
Old 02-09-2005, 12:44 PM   #3
trigggl
Member
 
Registered: Dec 2004
Location: Jacksonville, AR
Distribution: Debian Etch, AIX, Slackware
Posts: 117

Rep: Reputation: 15
How about total=.....$price - $price*.25
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Three ksh scripting questions liguorir Linux - Software 2 10-22-2005 12:40 PM
problematic case statement alaios Programming 4 08-24-2005 09:05 AM
KSH Scripting case statement..... ']['HeBroken Programming 1 12-10-2004 10:38 AM
bash'ed by case statement??? 3inone Programming 2 04-29-2004 04:52 PM
some ksh scripting nabil Programming 1 03-03-2002 10:34 PM


All times are GMT -5. The time now is 09:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration