06-23-2006, 07:24 PM
I have a few questions concerning the following code.
1. Is there a way to store my cost array as currency or would it be better to store it as a double? What is the code for double?
2. Is there a good way to have an idiot proof input? I want to be able to respond with custom message if the user enters a letter or word instead of a number.
1. Is there a way to store my cost array as currency or would it be better to store it as a double? What is the code for double?
2. Is there a good way to have an idiot proof input? I want to be able to respond with custom message if the user enters a letter or word instead of a number.
Code:
DIM n AS INTEGER
DIM day AS STRING
DIM items$(12)
items$(1) = "1 Partridge in a pear tree"
items$(2) = "2 Turtledoves"
items$(3) = "3 French hens"
items$(4) = "4 Calling birds"
items$(5) = "5 Gold rings"
items$(6) = "6 Geese-a-laying"
items$(7) = "7 Swans-a-swimming"
items$(8) = "8 Maids-a-milking"
items$(9) = "9 Ladies dancing"
items$(10) = "10 Lords-a-leaping"
items$(11) = "11 Pipers piping"
items$(12) = "12 Drummers drumming"
DIM cost(12)
cost(1) = 27.5
cost(2) = 25!
cost(3) = 5!
cost(4) = 70!
cost(5) = 60!
cost(6) = 25!
cost(7) = 1000!
cost(8) = 4.25
cost(9) = 289.5
cost(10) = 292.5
cost(11) = 95.75
cost(12) = 95!
CLS
1 INPUT "Enter a day from 1 to 12: ", day
day = CINT(day$)
IF day < 1 THEN
PRINT "Surely you can afford 1 day!"
SLEEP 7
GOTO 1
ELSEIF day > 12 THEN
PRINT "Don't be greedy!"
SLEEP 7
GOTO 1
END IF
FOR n = 1 TO day
PRINT items$(n), cost(n)
NEXT
END