Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PLz help
#11
This is a fairly antiquated method, but it should work:
Code:
CLS
PRINT "How many nails are in stock?"
INPUT a
PRINT "How many screws are in stock?"
INPUT b
PRINT "How many bolts are in stock?"
INPUT c
PRINT "How many flanges are in stock?"
INPUT d
PRINT "How many grommets are in stock?"
INPUT e

menu:
CLS
PRINT "1. Sell an Item"
PRINT "2. Return an Item"
PRINT "3. Inventory"
PRINT "4. Quit"
DO WHILE a$ = ""
a$ = INKEY$
LOOP

SELECT CASE a$
CASE IS = "1"
PRINT "Which item would you like to sell?"
PRINT "A. Nails"
PRINT "B. Screws"
PRINT "C. Bolts"
PRINT "D. Flanges"
PRINT "E. Grommets"

INPUT b$
IF b$ = "a" THEN a = a - 1
IF b$ = "b" THEN b = b - 1
IF b$ = "c" THEN c = c - 1
IF b$ = "d" THEN d = d - 1
IF b$ = "e" THEN e = e - 1

CASE IS = "2"
PRINT "Which item would you like to sell?"
PRINT "A. Nails"
PRINT "B. Screws"
PRINT "C. Bolts"
PRINT "D. Flanges"
PRINT "E. Grommets"
INPUT c$
IF c$ = "a" THEN a = a + 1
IF c$ = "b" THEN b = b + 1
IF c$ = "c" THEN c = c + 1
IF c$ = "d" THEN d = d + 1
IF c$ = "e" THEN e = e + 1

CASE IS = "3"
PRINT a, b, c, d, e,

CASE IS = "4"
END

END SELECT

GOTO menu
Notice the addition of the 4th menu option, the label right before the menu, and the GOTO after the SELECT block.
I'd knock on wood, but my desk is particle board.
Reply
#12
Quite the hypocrite, are we? Big Grin

I'd never do it like that. Instead, something like this is better:

Code:
CLS
PRINT "How many nails are in stock?"
INPUT a
PRINT "How many screws are in stock?"
INPUT b
PRINT "How many bolts are in stock?"
INPUT c
PRINT "How many flanges are in stock?"
INPUT d
PRINT "How many grommets are in stock?"
INPUT e

DO
CLS
PRINT "1. Sell an Item"
PRINT "2. Return an Item"
PRINT "3. Inventory"
PRINT "4. Quit"
DO WHILE a$ = ""
a$ = INKEY$
LOOP

SELECT CASE a$
case "4": EXIT DO
CASE IS = "1"
PRINT "Which item would you like to sell?"
PRINT "A. Nails"
PRINT "B. Screws"
PRINT "C. Bolts"
PRINT "D. Flanges"
PRINT "E. Grommets"

INPUT b$
IF b$ = "a" THEN a = a - 1
IF b$ = "b" THEN b = b - 1
IF b$ = "c" THEN c = c - 1
IF b$ = "d" THEN d = d - 1
IF b$ = "e" THEN e = e - 1

CASE IS = "2"
PRINT "Which item would you like to sell?"
PRINT "A. Nails"
PRINT "B. Screws"
PRINT "C. Bolts"
PRINT "D. Flanges"
PRINT "E. Grommets"
INPUT c$
IF c$ = "a" THEN a = a + 1
IF c$ = "b" THEN b = b + 1
IF c$ = "c" THEN c = c + 1
IF c$ = "d" THEN d = d + 1
IF c$ = "e" THEN e = e + 1

CASE IS = "3"
PRINT a, b, c, d, e,

END SELECT
LOOP
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#13
guys, guys! he said it's for class, so don't do his work for him! guide him, but don't show him.
Jumping Jahoolipers!
Reply
#14
i did the whole thing except i couldn't figure out how to loop it properly
thanks for the help
Reply
#15
This shows how to make a simple DO loop:
Code:
i = 0
DO
i = i + 1
PRINT i
IF i = 10 THEN EXIT DO
LOOP

Always keep logic in mind when programming! :wink:
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#16
Quote:Quite the hypocrite, are we? Big Grin
Come again? You're starting to get irritating. Tongue :rotfl: :barf:
I'd knock on wood, but my desk is particle board.
Reply
#17
Quote:This is a fairly antiquated method, but it should work
Well... he's right Big Grin...


for once Wink...
Reply
#18
Who's right?

It's an antiquated method which very few QB coders use, so I guess that would mean I'm right. Tongue

And anyways, I didn't wanna do the newbie's homework for him (as barok pointed out), so I just pointed him in the right direction...
I'd knock on wood, but my desk is particle board.
Reply
#19
No one said you were wrong. However, I'm still right. Big Grin
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#20
Quote:No one said you were wrong. However, I'm still right. Big Grin
We're both right. Now shaddap Wink Big Grin :rotfl:
I'd knock on wood, but my desk is particle board.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)