going from one loop to another, newbie here.
going from one loop to another, newbie here.
(OP)
I'm taking qbasic in school and we have to write a pice of software that manages an auction. Pretty much we're free to be creative and do what we want as long as the software works and you could be a complete idiot and not screw the program up. Right now it starts out fine, but has trouble in the middle. I have it ask for the name of the item, the starting price, the first bid which i made a do until loop so that the first bid has to be greater than the starting price, that works all fine....but then i want it to go to 'next bid' and only accept bids that are higher than the previous high bid. It jumps immediatly from after you enter a valid number for the 'first bid' to what i want it to do at the end....say the high bid, ask for the high-bidders name, and then say '(name) has won the (item)'
here is the code i have so far, if you can tell me what i'm doing wrong i would appreciate it bigtime. I want to get one step ahead in the class, and if i could bring in a stable and pretty reliable program on monday i would be happy.
CLS
PRINT "**AUCTION**"
PRINT " "
PRINT "To stop auction, enter 0"
PRINT " "
PRINT "Enter name of item "
INPUT item$
PRINT " "
PRINT "Enter starting price: "
INPUT minn
DO UNTIL low > minn
PRINT "Enter first bid: "
INPUT low
LOOP
DO UNTIL bid = 0
PRINT "Enter next bid"
INPUT bid
IF bid > min THEN bid = min
IF bid < min THEN bid = invalid
IF bid > min THEN bid = max
LOOP
PRINT "AUCTION ENDED"
PRINT " "
PRINT "High bid: "; max
PRINT "Enter name of high bidder: "
INPUT name$
PRINT name$; " has won the "; item$
END
here is the code i have so far, if you can tell me what i'm doing wrong i would appreciate it bigtime. I want to get one step ahead in the class, and if i could bring in a stable and pretty reliable program on monday i would be happy.
CLS
PRINT "**AUCTION**"
PRINT " "
PRINT "To stop auction, enter 0"
PRINT " "
PRINT "Enter name of item "
INPUT item$
PRINT " "
PRINT "Enter starting price: "
INPUT minn
DO UNTIL low > minn
PRINT "Enter first bid: "
INPUT low
LOOP
DO UNTIL bid = 0
PRINT "Enter next bid"
INPUT bid
IF bid > min THEN bid = min
IF bid < min THEN bid = invalid
IF bid > min THEN bid = max
LOOP
PRINT "AUCTION ENDED"
PRINT " "
PRINT "High bid: "; max
PRINT "Enter name of high bidder: "
INPUT name$
PRINT name$; " has won the "; item$
END
RE: going from one loop to another, newbie here.
I would suggest, inputing the bid one time right before the
second do loop. That way, bid will have something to start with then if it is zero it will go to the "AUCTION ENDED"
otherwise it will loop and ask again for another bid.
There are other ways to do it, but that would be the simplest modification for the program you have.
i.e. have an input for the bid in addition to the input for the bid within the do loop.
OR,
change the loop to:
DO
.
.
.
LOOP UNTIL BID=0