HELP! calculating student's average

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
jasonkidd007
Newbie
Posts: 8
Joined: Thu May 11, 2006 7:34 pm

HELP! calculating student's average

Post by jasonkidd007 »

1
Last edited by jasonkidd007 on Sun Jul 31, 2022 12:08 pm, edited 1 time in total.
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

So go get "professional" help from your teachers.
And get your fork homework off our forum!
I have left this dump.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Put more sanely:

We hate people that ask us to do their homework for them. After all, there ARE over 600 tutorials on this website.
Image
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Hey guys, I think we were a bit too rough on Jason. Yes, I agree, the post is about homework. However, he's not asking us to do the homework, he's just asking for a little help to fix it up. He also posted a pretty nice program so we can see that he's well ahead on doing the homework.

Give the kid a break!

*****
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: HELP! calculating student's average

Post by moneo »

jasonkidd007 wrote:......
The program is almost done, i just need professional help to perfect it.
Actually, you program looks good, but has a lot of problems, especially with the nested WHILE/WENDs.

One problem with WHILE/WENDs is that there is no EXIT WHILE. So try to use DO/LOOPs instead where you can get out with an EXIT DO.

Another alternative to your nested WHILE/WENDs is SELECT CASE. Have you used that yet?

By the way, you said you can't use IF, but you used two of them.

PRINT "Wow a mark of"; average; "Holy Cow!"
The reason this message prints in an infinite loop is because it takes the exit out of the WHILE/WEND when counter is >4, it later hits the WEND at the bottom of the program, loops back up to "WHILE numcourses > 0" and starts the counter at 15 all over again.

The last 2 WHILE/WENDs, where you set counter=1 and then loop WHILE counter=1, puts the program into an infinite loop also. What you want here is to get out (finish). Just do a SYSTEM or an END.

WHILE 90 < average <= 100
This is really strange syntax to me, and I've been programming Basic for over 30 years. I compiled your code and got no error, but I don't understand what this statement means.

Good luck.

*****
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

moneo wrote:Hey guys, I think we were a bit too rough on Jason. Yes, I agree, the post is about homework. However, he's not asking us to do the homework, he's just asking for a little help to fix it up. He also posted a pretty nice program so we can see that he's well ahead on doing the homework.

Give the kid a break!

*****
I'm afraid of Z!re. :wink:
Image
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Nathan1993 wrote: .....
I'm afraid of Z!re. :wink:
Nathan, you're not only witty, but you also have a great sense of humor.

*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
User avatar
Pete
Site Admin
Posts: 887
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete »

Guys, there's a difference between someone asking for someone to do their entire homework assignment for them, and someone asking for help on a homework assignment. As you can tell by the almost-finished program that jasonkidd007 wrote, he put in a valiant effort to finish the assignment, and just needed a little bit of help to get his code to work. This kind of post is precisely the reason why this forum exists.

Moneo: thanks for helping him out.
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Pete, thanks for posting your position on homework. I totally agree with you. That's why I went ahead and tried to help him.

Regards..... Moneo
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

moneo wrote:Pete, thanks for posting your position on homework. I totally agree with you. That's why I went ahead and tried to help him.

Regards..... Moneo
i agree thanks for helping him moneo...

he did make an effort... he just didnt make a blank
question asking for help or a weak 3-4 line attempt
at something....
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.

*****
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

moneo wrote:Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.

*****
What a surprise...
But yeah, I was harsher than needed, because I forgot to check his postcount. This guy actually has one, and so I should just have left the topic without posting at all. My bad.
I have left this dump.
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Z!re wrote:
moneo wrote:Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.

*****
What a surprise...
But yeah, I was harsher than needed, because I forgot to check his postcount. This guy actually has one, and so I should just have left the topic without posting at all. My bad.
Not to worry. You're kind of post helps to clear the air, and keeps them on their toes.

*****
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Re: HELP! calculating student's average

Post by Patz QuickBASIC Creations »

moneo wrote:WHILE 90 < average <= 100
This is really strange syntax to me, and I've been programming Basic for over 30 years. I compiled your code and got no error, but I don't understand what this statement means.
Hmm... It doesn't seem like this would work. Usually $$$ like this will require an AND statement. WHILE 90<average AND average <=100 is usually what it would be. The only use I could think of for this is detecting if the grade went over 100 somehow or became too low (below 90). I'll have to look into this!
bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm »

moneo wrote:Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.
Or he visited here before Sun Oct 01, 2006 1:11 am and is now too scared :wink:

Code: Select all

 WHILE 90 < average <= 100 
So while 90 is smaller than average that is hundred or less? :lol:
Never seen anything like that. I hope jasonkidd007 comes back and tells what he means (or tried to mean) with that one.
Bulldog
Newbie
Posts: 7
Joined: Wed Aug 09, 2006 9:30 am

Post by Bulldog »

Well no if's hope it works ok. You could also use SELECT CASE but I assumed you wanted only DO LOOP / WHILE WEND.



'Filename: KTDOFOR.BAS
'
'Variable Dictionary
' numcourses - the total number of courses the student took
' total - a running total of all the student's marks
' mark - a mark in one course
' counter - a counter to keep track of the number of times a message
' is printed
' average - the average of all the students marks
'
CLS
PRINT "This program will determine your average on last year's courses"
PRINT "When you have finished entering marks, type a negative number."
PRINT

numcourses = 0
total = 0

DO
'This section makes sure a valid mark is entered
'
DO
CLS
LOCATE 2, 1
INPUT "Please enter a mark ", mark
LOOP UNTIL mark <= 100 AND mark >= 0
tmp = mark

'Increment total and counter
'
numcourses = numcourses + 1
total = total + mark

'Special message for a high mark
'

DO WHILE mark >= 90
counter = 0
PRINT
DO
PRINT "A mark of"; mark; "! Wow!"
counter = counter + 1
LOOP UNTIL counter = 10
Counter = 0
PRINT "Press a key to enter next mark"
PRINT
SLEEP
WHILE LEN(INKEY$): WEND
EXIT DO
LOOP

LOOP WHILE (tmp > 0)

'Make sure at least one mark was entered
'
DO WHILE numcourses > 0
average = total / numcourses

'Special message for a high average
'
DO WHILE average > 90
counter = 15
WHILE counter > 4
counter = counter - 1
PRINT "Wow a mark of"; average; "Holy Cow!"
WEND
EXIT DO
LOOP
DO WHILE average < 90
CLS
PRINT "Your average last year was"; average
EXIT DO
LOOP

DO WHILE average = 0
CLS
PRINT "No marks were entered"
EXIT DO
LOOP
EXIT DO
LOOP





END
Post Reply