I'm going to put this assignment to bed...

by Pete (Login The-Universe)
Admin

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
GOSUB menu
IF choice = "X" THEN EXIT DO
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:"; tax
PRINT "Total price: "; totalprice + 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
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:";
REM Round down tax
tax = totalprice * tax: tax = tax * 100: tax = INT(tax): tax = tax / 100
PRINT 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

shipping:
DO
PRINT "Shipping packages"
PRINT
PRINT
PRINT "bronze 2% tax + 4-6 week shipping"
PRINT "silver 5% tax + 2-4 week shipping"
PRINT "gold 10% tax + 1-2 week shipping"
PRINT
INPUT "Choose a package for shipment: "; shiptype
SELECT CASE shiptype
CASE "bronze": tax = .02
EXIT DO
CASE "silver": tax = .05
EXIT DO
CASE "gold": tax = .1
EXIT DO
CASE ELSE
PRINT
PRINT "Invalid: Please choose a package"
END SELECT
LOOP
RETURN

--------------------------------------

Try it and tell me if it works the way it is supposed to.

You were so close and did so well with incorporating the other methods that I don't want to drag it out. Al you missed is rounding the tax. (See the REM statement for that method and see if it makes since to you. If your teacher doesn't care about rounding, you can remove it.)

In that DO/LOOP, WHILE doesn't cut it, because you need to exit as soon as "X" is pressed. You just get rid of the WHILE, which won't be true until the other two gosubs are finished, and add an exit do condition. That takes you to your final receipt.

Another change is spacing. You don't need to add spaces with positive variables. There is a space in front and in back automatically included.

The only other thing you missed as far as I could tell was a formula to add the tax and change the tax variable from the percents to the actual dollar amount. So you assignment is such that tax does both. If that is unacceptable, you will need to make another variable. I would recommend calling it taxrate. Replace tax with taxrate and make tax the totalprice * taxrate. That's up to you.

You are welcome back to ask for help on other assignments at any time.

Pete

Posted on Dec 10, 2009, 8:10 PM

Respond to this message   

Return to Index


Response TitleAuthor and Date
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