Qbasicnews.com
August 13, 2020, 09:25:00 PM *
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]
  Print  
Author Topic: Hockey Program (HELP!:S)  (Read 1465 times)
Dr_Suess
New Member

Posts: 9


« on: May 14, 2003, 08:35:19 PM »

Hey guys, its me again. I took what u guys said to heart, about trying the program first, and so here i am....stuck.

The program requires me to print out all the players stats and numbers, names etc... in a chart......and also at the bottom of the screen print out the person with most goals, and person with least goals...........here, goals count as 2 points and assists as 1.

heres what i have so far.....

CLS
FOR i% = 1 TO 16
    READ name$, num%, goals%, assis%, gamewon%, pnts%
    pnts% = (goals% * 2) + assis%
NEXT i%

DATA "Smith",24,5,19,2,pnts%
DATA "Watson",45,5,20,3,pnts%
DATA "Harrison",7,3,21,2,pnts%
DATA "Bradshaw",15,2,19,5,pnts%  
DATA "Clemence",17,0,17,6,pnts%
DATA "Williams",21,0,12,4,pnts%
DATA "Parks",25,10,21,5,pnts%
DATA "Daubs",28,4,22,8,pnts%
DATA "Oaks",29,1,17,7,pnts%
DATA "Lyons",30,6,18,7,pnts%
DATA "Caryle",32,1,21,4,pnts%    
DATA "Jennings",37,4,10,1,pnts%
DATA "Ewing",43,4,22,2,pnts%
DATA "Gilles",49,5,18,2,pnts%
DATA "Falks",55,8,19,0,pnts%
DATA "Redding",99,9,19,5,pnts%

Its not working...please , i need help......

thanx bye
Logged

A lie told often enough, becomes the truth"
toonski84
__/--\__
*****
Posts: 2567



« Reply #1 on: May 14, 2003, 08:37:50 PM »

I dont understand why you have pnts% at the end of each data statement.  If it's a string you must put it in quotes, and if it's not a number it'll return a syntax error.
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Dr_Suess
New Member

Posts: 9


« Reply #2 on: May 14, 2003, 08:39:26 PM »

i have them there, because its the total points are equal to goals x 2 plus the assists, and its numerical

any help or advice?
Logged

A lie told often enough, becomes the truth"
Meg
Ancient QBer
****
Posts: 483


« Reply #3 on: May 14, 2003, 09:29:35 PM »

first, get rid of the pnts% at the end of each data line, and also get rid of it from your READ line:

Code:
CLS
FOR i% = 1 TO 16
  READ name$, num%, goals%, assis%, gamewon%
  pnts% = (goals% * 2) + assis%
NEXT i%

DATA "Smith",24,5,19,2
DATA "Watson",45,5,20,3
DATA "Harrison",7,3,21,2
DATA "Bradshaw",15,2,19,5
DATA "Clemence",17,0,17,6
DATA "Williams",21,0,12,4
DATA "Parks",25,10,21,5
DATA "Daubs",28,4,22,8
DATA "Oaks",29,1,17,7
DATA "Lyons",30,6,18,7
DATA "Caryle",32,1,21,4
DATA "Jennings",37,4,10,1
DATA "Ewing",43,4,22,2
DATA "Gilles",49,5,18,2
DATA "Falks",55,8,19,0
DATA "Redding",99,9,19,5


What this will do is loop 16 times.  Each loop will read one line of data, and calculate pnts% one time.

Now, as far as printing them out in a chart, and printing out the person with the most (and least) goals:

If you want the chart to be in some kind of ORDER (i.e. alphabetically sorted by last name, or by points, or by jersey number, or whatever) then I recommend reading the values into an array.

If you haven't learned arrays yet in your class, then odds are you don't need to display the players in any kind of order.  If this is the case, you just need to add in a PRINT (or PRINT USING, if you want it all nice and neat-looking) statement inside the loop after you calculate pnts%

If you HAVE learned arrays, then you need to put the values into the array inside your loop after you read in the data and calculate points.  Then you need to sort the array.  Then you need to print out the chart.

For finding the person with the most (or fewest) points, I'd just make a couple variables called HighPoints% and LowPoints%, and every time you read in DATA values, compare them to the current HighPoints% and LowPoints% and if they're higher (or lower), then change HighPoints% and LowPoints% to equal them.  Get it?

it would look something like this:

for i% = 1 to 16
  READ in the data
  CALCULATE pnts%
  IF pnts% <= LowPoints% then
  IF pnts% >= HighPoints% then
next i%
Logged
Pages: [1]
  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!