LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


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

Rep: Reputation: 15
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
 
Old 12-10-2004, 11:38 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
There are not errors in code, bur maybe math confusion ?

x / .25 = x * 4
 
  


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 01:40 PM
problematic case statement alaios Programming 4 08-24-2005 10:05 AM
Case Statement With Aix Ksh Scripting ']['HeBroken AIX 2 02-09-2005 01:44 PM
bash'ed by case statement??? 3inone Programming 2 04-29-2004 05:52 PM
some ksh scripting nabil Programming 1 03-03-2002 11:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:07 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration