HELP! calculating student's average
-
- Newbie
- Posts: 8
- Joined: Thu May 11, 2006 7:34 pm
HELP! calculating student's average
1
Last edited by jasonkidd007 on Sun Jul 31, 2022 12:08 pm, edited 1 time in total.
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!
*****
Give the kid a break!
*****
Re: HELP! calculating student's average
Actually, you program looks good, but has a lot of problems, especially with the nested WHILE/WENDs.jasonkidd007 wrote:......
The program is almost done, i just need professional help to perfect it.
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.
*****
- {Nathan}
- Veteran
- Posts: 1169
- Joined: Thu Aug 19, 2004 6:08 pm
- Location: The wetlands of central Ohio, USA
- Contact:
I'm afraid of Z!re.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!
*****
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: thanks for helping him out.
i agree thanks for helping him moneo...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
he did make an effort... he just didnt make a blank
question asking for help or a weak 3-4 line attempt
at something....
What a surprise...moneo wrote:Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.
*****
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.
Not to worry. You're kind of post helps to clear the air, and keeps them on their toes.Z!re wrote:What a surprise...moneo wrote:Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.
*****
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.
*****
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
Re: HELP! calculating student's average
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!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.
-
- Veteran
- Posts: 288
- Joined: Sat Feb 18, 2006 4:02 pm
Or he visited here before Sun Oct 01, 2006 1:11 am and is now too scaredmoneo wrote:Yeah, but like many others, he hasn't come back to acknowledge the help given nor anything.
Code: Select all
WHILE 90 < average <= 100
Never seen anything like that. I hope jasonkidd007 comes back and tells what he means (or tried to mean) with that one.
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
'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."
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
DO
PRINT "A mark of"; mark; "! Wow!"
counter = counter + 1
LOOP UNTIL counter = 10
Counter = 0
PRINT "Press a key to enter next mark"
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