Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help with a loop
#1
I am writing a program for school that needs to input a name and and number of minutes used by a band in a studio. It needs to continue asking for a name and minutes until quit is entered. Then it needs to output the band name, the minutes used , and the charges. Then I need a total number of minutes and charges. I am having problems outputing the band names. the way I and doing it only outputs the last name entered. Not all the names.

how am I suposed to keep the band names in memory until it is printed. Here is what I got so far.

CLS
INPUT "Enter the name of the group or quit to end"; group$
INPUT "Enter the number of minutes"; min
DO UNTIL UCASE$(group$) = "QUIT"
total = total + min
INPUT "Enter the name of the group or quit to end"; group$
INPUT "Enter the number of minutes"; min
PRINT group$, total

LOOP
PRINT TAB(30); "Recording Studio Charges"

chrg = (200 / 60) * total
chrg = INT(chrg * 100 + .5) / 100
PRINT "Name of group "; group$
PRINT "Number of minutes"; total
PRINT "Total charges = $"; chrg
END


any help would be apriciated.
Reply
#2
.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#3
You and atomicfrog in the same class per-chance Wink

http://forum.qbasicnews.com/viewtopic.php?t=2982
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#4
Quote:You and atomicfrog in the same class per-chance Wink

http://forum.qbasicnews.com/viewtopic.php?t=2982

I noticed that too!
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#5
Glenn's suggestion of using an array works fine.

Alternatively, you could open up a text file (chack out the "OPEN" command in QBHelp) and do a loop like you've got there. Each time the user enters a band name and minutes, you could add it to the text file. Then, when they enter quit, you could close the text file, reopen it ("OPEN" again, but this time as INPUT [reading FROM the file] instead of as OUTPUT [writing TO the file]) and print the values one at a time.

Commands needed for glenn's idea:

DIM

other fun, helpful commands: REDIM, TYPE

Commands needed for my idea

OPEN, CLOSE

other fun, helpful commands: EOF

look 'em all up. QBHelp is the best place to learn! Go through and read all the commands some time.

*peace*

Meg.
Reply
#6
Is this a marked assignment? If so, take the above suggestion and output the results to file. It's not something thats beginner, so you should get more marks for it. You should have an array, it will be much easier to manage.

With a file, just output each name as a new line, with like a number of total above that, like:

3
Bob
Bill
Bret

3 names
name1
name2
name3
get it?

Just store a var like countNames% and add 1 to the loop

Pretty strange way, but it works...

Hail.
·~¹'°¨°'¹i|¡~æthérFòx~¡|i¹'°¨°'¹~·-
avinash.vora - http://www.avinashv.net
Reply
#7
LoL THIS IS NOT HELPFUL but...

Glenn! It took me awhile to read the subject title and not just the

.


lol. Nevermind. Cry
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#8
(Ha. I kill me!)
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#9
Oh, very funny.
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
#10
:o
Believing in reincarnation or life after death or somthing Glenn?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)