Qbasicnews.com
March 28, 2020, 04:50:19 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Accumulator Problem  (Read 8867 times)
JJRJRM143
New Member

Posts: 7


« on: January 19, 2004, 02:48:14 PM »

Ok I have most of the program done but I can't figure out where to insert my accumulators for gender. It should be like

tot.male = tot.male + male and
tot.female = tot.female + female

Code:

GOSUB Start
GOSUB Process
GOSUB Finish
END

Start:
PRINT "                               NORWOOD HIGH SCHOOL"
PRINT "                              ROOM ASSIGNMENT REPORT"
PRINT "                              ======================"
PRINT
PRINT
PRINT "Room               Student"
PRINT
D1$ = "\   \           \               \"
T1$ = "Male Students = #"
T2$ = "Female Students = #"
T3$ = "Total Students For Room = #"
T4$ = "Total Male Students = ##"
T5$ = "Total Female Students = ##"
T6$ = "Total Students = ##"
READ room$, name$, gender$
hold.room$ = room$
RETURN

Process:
DO UNTIL room$ = "EOF"
  IF hold.room$ = room$ THEN
    IF gender$ = "M" THEN
      male = male + 1
    ELSE
      female = female + 1
    END IF
    count = count + 1
    PRINT USING D1$; room$; name$
  ELSE
    PRINT USING T1$; male
    PRINT USING T2$; female
    PRINT USING T3$; count
    PRINT
    count = 0
    male = 0
    female = 0
    hold.room$ = room$
    PRINT USING D1$; room$; name$
    count = count + 1
    male = male + 1
  END IF
  tot.count = tot.count + 1
  READ room$, name$, gender$
LOOP
RETURN

Finish:
PRINT USING T1$; male
PRINT USING T2$; female
PRINT USING T3$; count
PRINT
PRINT USING T4$; tot.male                
PRINT USING T5$; tot.female
PRINT USING T6$; tot.count
RETURN





DATA 101, Joseph Bishop, M
DATA 101, Paul Burke, M
DATA 101, Marge Hackett, F
DATA 101, Beth Foster, F
DATA 101, Julia Jefferson, F
DATA 101, Daniel Munn, M
DATA 101, Barbara Tipton, F
DATA 202, Patrick Collins, M
DATA 202, Kyle Durkee, M
DATA 202, Brian Luire, M
DATA 202, Miguel Perez, M
DATA 202, Nancy Symans, F
DATA 202, George Fassio, M
DATA 303, Charles Howard, M
DATA 303, Virginia Murray, F
DATA 303, Carol Palm, F
DATA 303, Daniel Thomas, M
DATA 303, Carl Tross, M
DATA 303, Lindsey West, F
DATA 303, Stephanie Wyatt, F
DATA EOF,,


Your help is greatly appreciated
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #1 on: January 19, 2004, 02:53:57 PM »

Maybe you should try a little harder before asking for homework help?

Just a suggestion:

Quote

IF gender$ = "M" THEN
male = male + 1


Look there.

And do your own damn homework. *argh!*

 :rotfl:
Logged
JJRJRM143
New Member

Posts: 7


« Reply #2 on: January 19, 2004, 03:02:21 PM »

Damn Z!re, someone woke up on the wrong side this morning.

I case you did'nt understand I'm trying to total up the male and female students and add them at the end. Those lines you pointed out are just fine

Ya crabby bastard
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #3 on: January 19, 2004, 03:04:51 PM »

...We just have a policy here of trying to get people to do their own homework, or else they won't learn anything, and the QB teacher's efforts will go to waste.
Don't flame.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #4 on: January 19, 2004, 03:11:39 PM »

Quote from: "JJRJRM143"
Damn Z!re, someone woke up on the wrong side this morning.

I case you did'nt understand I'm trying to total up the male and female students and add them at the end. Those lines you pointed out are just fine

Ya crabby bastard


If you had half a brain, you would know that he was giving you a hint. And if you want people to help you, calling them names probably won't get you off to a very good start.
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #5 on: January 19, 2004, 03:30:51 PM »

Also, note the smiley " :rotfl: " I was making a joke, relax.

It is a simple problem, to me it looks like you took a quick peek and then decided to go watch Tv instead and let us do it for you.

The code you posted is copied right off the assignment.

You have not made any changes to it (that I can see anyways)

We will NOT do your homework, we WILL help you all we can, but ask a question on your work so far.

I know the lines i pointed out was fine, but you should listen more in class you "crabby bastard", and stop watching TV, drinking bear, having sex, playing sports.

My advice: become a monk.. or Stare into a wall, it would do you good  :rotfl:

Code:

IF you = offended THEN iWasMakingaJoke=TRUE:doYourOwnHomework = TRUE ELSE doYourOwnHomework = TRUE
Logged
stevie
Member
*
Posts: 43


« Reply #6 on: January 19, 2004, 03:32:50 PM »

personally, I think this guy did it right: He posted what he had and he asked for help on a specific part. Z!ire was very much in the wrong. Granted, the newb shooting back with an insult probably wasn't a great move either but I can't say that I wouldn't have done the same in his position.

BTW -- at first glance it looks like you might be resetting all your count variables within the loop, which means no matter how many times you add 1 to it, it's going back to 0 when it reaches those lines.
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #7 on: January 19, 2004, 03:44:58 PM »

Quote from: "stevie"
Z!ire was very much in the wrong.lines.


I know the assignment:
you get the exact same code JJRJRM143
the assignment:

add tot.males and tot.females and make it display those values at the end of the program

Now. Please tell me what he wanted help with?

Ohh and by the way stevie, I have an english essay, heres what I have:

Once upon a time.

I have to make it a A+ essay until tomorrow, can you please help me?

No offense intended, just making my point.  Cool
Logged
Diroga
Been there, done that
*****
Posts: 1087


« Reply #8 on: January 19, 2004, 03:46:28 PM »

you should be thankful that you have a qb class. i dont... Sad
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #9 on: January 19, 2004, 03:48:10 PM »

You should be thankful you have *any* computers/programming course - I don't have any.
People obviously think that only those above the age of 14 are worthy to study programming. :roll:
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
stevie
Member
*
Posts: 43


« Reply #10 on: January 19, 2004, 04:13:16 PM »

Z!RE -- fair enough, I didn't realize that all the code he pasted was supplied to him.
Logged
JJRJRM143
New Member

Posts: 7


« Reply #11 on: January 19, 2004, 04:51:42 PM »

First off, let me start by saying that I did not in any way just copy & paste this code. I coded the entire thing last night. What I got from my teacher was a paper stating the DATA and the format he wanted it displayed in. So it pissed me off even more to see Z!re saying that he knew for a fact that I copied it and did'nt do a thing. I take my programming class very seriously as this is what I want to do for a living. So Z!re make sure you know exactly what you're talking about before you go off shooting your mouth

Second, I fixed it on my own

Code:

GOSUB Start
GOSUB Process
GOSUB Finish
END

Start:
PRINT "                               NORWOOD HIGH SCHOOL"
PRINT "                              ROOM ASSIGNMENT REPORT"
PRINT "                              ======================"
PRINT
PRINT "Room                Student"
PRINT
D1$ = "\   \           \               \"
T1$ = "Male Students = #"
T2$ = "Female Students = #"
T3$ = "Total Students For Room \ \ = #"
T4$ = "Total Male Students = ##"
T5$ = "Total Female Students = ##"
T6$ = "Total Students = ##"
READ room$, name$, gender$
hold.room$ = room$
RETURN

Process:
DO UNTIL room$ = "EOF"
  IF hold.room$ = room$ THEN
    IF gender$ = "M" THEN
      male = male + 1
      tot.male = tot.male + 1
    ELSE
      female = female + 1
      tot.female = tot.female + 1
    END IF
    old.room$ = room$
    count = count + 1
    PRINT USING D1$; room$; name$
  ELSE
    PRINT USING T1$; male
    PRINT USING T2$; female
    PRINT USING T3$; old.room$; count
    PRINT
    count = 0
    male = 0
    female = 0
    hold.room$ = room$
    PRINT USING D1$; room$; name$
    count = count + 1
    male = male + 1
    tot.male = tot.male + 1
  END IF
  tot.count = tot.count + 1
  READ room$, name$, gender$
LOOP
RETURN

Finish:
PRINT USING T1$; male
PRINT USING T2$; female
PRINT USING T3$; old.room$; count
PRINT
PRINT "==========================="
PRINT USING T4$; tot.male
PRINT USING T5$; tot.female
PRINT USING T6$; tot.count
PRINT "==========================="
RETURN





DATA 101, Joseph Bishop, M
DATA 101, Paul Burke, M
DATA 101, Marge Hackett, F
DATA 101, Beth Foster, F
DATA 101, Julia Jefferson, F
DATA 101, Daniel Munn, M
DATA 101, Barbara Tipton, F
DATA 202, Patrick Collins, M
DATA 202, Kyle Durkee, M
DATA 202, Brian Luire, M
DATA 202, Miguel Perez, M
DATA 202, Nancy Symans, F
DATA 202, George Fassio, M
DATA 303, Charles Howard, M
DATA 303, Virginia Murray, F
DATA 303, Carol Palm, F
DATA 303, Daniel Thomas, M
DATA 303, Carl Tross, M
DATA 303, Lindsey West, F
DATA 303, Stephanie Wyatt, F
DATA EOF,,


And thanks for sticking up for me stevie, I code a prog and just because I can't figure 1 thing out and come here for help as this is a QBasic board ppl jump down my throat, screw this, I'll just stick to my regular board I goto even though they are not as experienced with QBasic as you guys are

*peace out and thanks to those who actually helped*
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #12 on: January 19, 2004, 04:58:24 PM »

Whoah. I think that the moral of the story is: "Even when hungry, the fox should not steal the chicken when the farmer is looking."
Logged

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.
stevie
Member
*
Posts: 43


« Reply #13 on: January 19, 2004, 05:19:14 PM »

JJ: Sorry for doubting you

Z!re: lying to make your point makes you look like a toolbox.

I rescind my apology.
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #14 on: January 19, 2004, 06:25:52 PM »

Seriously, I don't care, I just wanted to help JJRJRM143 out by giving a hint to a code (which IF he had coded it himself) would have been simple to fix, and if he takes hes programming course seriously it wouldn't be a problem, as the teacher or hes book explains how to do it (I am sure of it, teachers do not give unsolvable assigments, ey  :wink: )

The code contains stuff that makes atleast me doubt that JJRJRM143 coded it himself and then had trouble adding a tot.n counter.

I never intended any offense by my posts, so why do you jump at me?

It was he who insulted me not the other way around.
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!