Qbasicnews.com
February 22, 2020, 06:59:11 PM
 Pages: 1 [2]
 Author Topic: Newbie workin on class project need some insight  (Read 6494 times)
Don W
New Member

Posts: 14

 « Reply #15 on: May 11, 2004, 02:02:07 AM »

Plasma, Thanks for the help.  I understand the "print using" line but could your explain how the the "topay=topay + grpay"  It works but I really want to understand what its doing.  I may not use Qbasic forever but I no what I learn here will help me with other languages I will need to learn before I get my degree.  Atleast that my take on it!

Thanks again

Don
 Logged

assman exits stage left
Plasma
Na_th_an

Posts: 1770

 « Reply #16 on: May 11, 2004, 02:39:19 AM »

Think like a computer...

At the beginning of your program, topay = 0 (because QB is nice and initializes all variables to 0)

The first time through the "loop", the employee is Alley Oop, and you calculate grpay to be 250. topay is then set to itself (currently 0), plus grpay (currently 250), so topay now = 250.

The second time through, employee is Jack Daniels, grpay is now 312. Again, topay is set to itself (currently 250), plus grpay (currently 312), so topay now = 562

The third time through, employee is Johnny Walker, grpay is calculated to be 260. Topay is yet again set to itself (currently 562), plus grpay (currently 260), making topay = 822

Your program now exits the loop with topay equal to the sum of all the payments.

Your method (topay = grpay + grpay + grpay) doesn't work because you are changing grpay for each iteration of the loop. Unless you save the value of grpay somewhere at the end of the loop (in an array, for example), it's changed the next time around. So when you tell the computer to set the topay to grpay + grpay + grpay, you're just saying topay = grpay * 3, because grpay is always the same.
 Logged
Don W
New Member

Posts: 14

 « Reply #17 on: May 11, 2004, 02:52:41 AM »

Thanks man!  Thats just what I needed.  it makes sense to me now.  :bounce:  So as long as the terminator statement is not met, it will keep adding grpay, correct?

Thanks for takin the time to "show me the light"

Don
 Logged

assman exits stage left
Torahteen
Ancient Guru

Posts: 744

 « Reply #18 on: May 11, 2004, 12:41:08 PM »

Glad I could help. Oh, and I noticed that I forgot to use quotes ("")on my print lines. What plasma said is a good idea, I use it alot.
 Logged

quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Don W
New Member

Posts: 14

 « Reply #19 on: May 11, 2004, 04:23:27 PM »

Code:
QBASIC:
CLS
END

Ok back to the books!!!
 Logged

assman exits stage left
Torahteen
Ancient Guru

Posts: 744

 « Reply #20 on: May 11, 2004, 04:58:22 PM »

Quote
Ok back to the books!!!

Assuming you are talking about me.  :rotfl:[/quote]
 Logged

quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Don W
New Member

Posts: 14

 « Reply #21 on: May 11, 2004, 05:08:33 PM »

No, no, I am sorry.  I was trying to highlight that code, and it did not work....so back to the books for me.  I have been reading past post and thought was understanding what Oracle had posted to me.  Alteast I know how to post the code in a cool box now.
 Logged

assman exits stage left
whitetiger0990
__/--\__

Posts: 2964

 « Reply #22 on: May 11, 2004, 05:22:00 PM »

to highlight it its

[syntax="qbasic"]PRINT "yo"[/syntax]
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Don W
New Member

Posts: 14

 « Reply #23 on: May 11, 2004, 05:24:53 PM »

I did it wrong again.
 Logged

assman exits stage left
whitetiger0990
__/--\__

Posts: 2964

 « Reply #24 on: May 11, 2004, 05:26:57 PM »

no... it's

[syntax="qbasic"]
'Put code here
[/syntax]
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Torahteen
Ancient Guru

Posts: 744

 « Reply #25 on: May 11, 2004, 05:37:38 PM »

Oh :lol: , hehe. I thought you were saying I needed to go back to the books for forgeting something so simple.

I'll try it.

[syntax="qbasic]
Code:

PRINT "I can't beleive I thought that"

PRINT "You think he is dumb?! That's not nice"

ELSE PRINT "Oh, good. I was afraid you'd say yes."

[/syntax]

Edit, I put the syntax tags outside.
Edit 2,   Hmm...
 Logged

quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
whitetiger0990
__/--\__

Posts: 2964

 « Reply #26 on: May 11, 2004, 05:46:36 PM »

dont put code tags
you forgot the end quote =P

in the code you forgot the END IF
the input isn't a string

[syntax="qbasic"]PRINT "I can't beleive I thought that"
PRINT "You think he is dumb?! That's not nice"
ELSE
PRINT "Oh, good. I was afraid you'd say yes."
END IF[/syntax]
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Torahteen
Ancient Guru

Posts: 744

 « Reply #27 on: May 11, 2004, 06:34:49 PM »

Hehe, I knew that.
 Logged

quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Don W
New Member

Posts: 14

 « Reply #28 on: May 11, 2004, 07:18:20 PM »

something so simple and I can't get it
 Logged

assman exits stage left
Don W
New Member

Posts: 14

 « Reply #29 on: July 14, 2004, 06:32:37 PM »

Just wanted to thank everyone for there help on this one, I PASSED!

Thanks again

Don
 Logged

assman exits stage left
 Pages: 1 [2]