Is this what you meant?

by JP (no login)

 
CLS
DIM choice AS STRING
DIM pick AS STRING
DIM price AS INTEGER
DIM numitems AS SINGLE
DIM shiptype AS STRING
DIM bronze AS SINGLE
DIM silver AS SINGLE
DIM gold AS SINGLE
DIM tax AS SINGLE
DIM item AS STRING
DIM validchoice AS STRING
DIM validpick AS STRING
DIM totalprice AS SINGLE
DIM totalnumitems AS SINGLE
bronze = .02
silver = .05
gold = .1
DO WHILE choice <> "X"
GOSUB menu
GOSUB pricing
GOSUB shipping
GOSUB receipt
LOOP
finalreceipt:
CLS
PRINT
PRINT
PRINT
PRINT
PRINT "Total cost: "; totalprice; ""
PRINT "Total items ordered: "; totalnumitems
PRINT "Shipping: "; shiptype
PRINT "Tax: "; totalprice * tax
PRINT "Total price: "; totalprice * (1 + tax)
PRINT
PRINT
PRINT
PRINT "Thank you for shopping at JP's (:D)"
END

receipt:
IF validchoice = "K" THEN
CLS
IF choice <> "x" THEN
PRINT "Invalid selection: You must choose a letter from A through J OR X to finish your order(s)"
END IF
ELSE
PRINT
PRINT
PRINT "Enter the amount of "; item; " you would like to order: ";
INPUT "", numitems
PRINT "Bronze includes a 2% tax and 4-6 week ship date"
PRINT "Silver includes a 5% tax and 2-4 week ship date"
PRINT "Gold includes a 10% tax and a 1-2 week ship date"
PRINT
INPUT "Shipping (bronze, silver or gold): ", shiptype
CLS
totalprice = totalprice + price * numitems
totalnumitems = totalnumitems + numitems
PRINT "You purchased "; numitems; " "; item; "(s) for: "; price * numitems; "using the "; shiptype; " package"
PRINT "Total price: "; totalprice; " Total quantity: "; totalnumitems; "Total tax: "; totalprice * tax
END IF
RETURN

pricing:
validchoice = "T"
SELECT CASE choice
CASE "A"
item = "Packard Bell"
price = 25
CASE "B"
item = "Macintosh"
price = 20
CASE "C"
item = "Sim City 2000 (PC)"
price = 7
CASE "D"
item = "Sim Earth (PC)"
price = 6
CASE "E"
item = "Box of floppy disks (50)"
price = 10
CASE "F"
item = "Kaypro laptop"
price = 20
CASE "G"
item = "Commodore 64"
price = 17
CASE "H"
item = "Sirius Computer"
price = 19
CASE "I"
item = "Oregon Trail (DOS)"
price = 5
CASE "J"
item = "Zork (Commodore 64)"
price = 6
CASE ELSE
validchoice = "K"
END SELECT
RETURN

menu:
PRINT
PRINT
PRINT " JP's Awesome Online Store"
PRINT
PRINT
PRINT " A. Packard Bell $ 25"
PRINT " B. Macintosh $ 20"
PRINT " C. Sim City 2000 (PC) $ 7"
PRINT " D. Sim Earth (PC) $ 6"
PRINT " E. Box of floppy disks (50) $ 10"
PRINT " F. Kaypro laptop $ 20"
PRINT " G. Commodore 64 $ 17"
PRINT " H. Sirius Computer $ 19"
PRINT " I. Oregon Trail (DOS) $ 5"
PRINT " J. Zork (Commodore 64) $ 6"
PRINT " X. View receipt"
PRINT
INPUT " Choose the item you'd like to purchase: ", choice
choice = UCASE$(choice)
RETURN

shippingmenu:
PRINT
PRINT
PRINT "Shipping packages"
PRINT
PRINT
PRINT " a. Bronze 2% tax + 4-6 week shipping"
PRINT " b. Silver 5% tax + 2-4 week shipping"
PRINT " c. Gold 10% tax + 1-2 week shipping"
PRINT " z. Cancel"
PRINT
INPUT " Choose the package you'd like to use: ", pick
pick = LCASE$(pick)
RETURN

shipping:
SELECT CASE shiptype
CASE "bronze": tax = .02
CASE "silver": tax = .05
CASE "gold": tax = .1
END SELECT
RETURN

Posted on Dec 10, 2009, 6:05 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
I switched browsers and I forgot to post this before the code of the last post...JP on Dec 10
 * Add a CASE ELSE before the END SELECT and use that. on Dec 10
  I must still be doing it wrong, getting no effect from itJP on Dec 10
 Clippy is correct...Pete on Dec 10
  I tried the DO LOOP and got somewhere--sort ofJP on Dec 10
   I'm going to put this assignment to bed...Pete on Dec 10
    Its better, but not quite there still...JP on Dec 10
     You just had a couple more things to address...Pete on Dec 10
      YayJP on Dec 10
       * You're welcome. I hope what you learned here makes the next assignment a little easier.Pete on Dec 10

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement