Need help with Arrays

Reply

Join Date: Sep 2004
Posts: 1
Reputation: Katie G is an unknown quantity at this point 
Solved Threads: 0
Katie G Katie G is offline Offline
Newbie Poster

Need help with Arrays

 
0
  #1
Oct 31st, 2004
Newbie to QB - I have an assignment to create a grade sheet for one student. Must list name, instructor, class, test grades 1 through 5, average, low grade, high grade and new average with lowest grade dropped. I am so confused about arrays. I am using examples from class but I can't seem to get it to work. Anyone's help is appreciated. Here is what I have so far:

'****DIMENSION STATEMENTS****
DIM STU AS STRING
DIM CLASS AS STRING
DIM TEACH AS STRING
DIM GRADE (1 TO 5) AS INTEGER
DIM AVG AS SINGLE
DIM NEWAVG AS SINGLE
DIM LOW AS SINGLE
DIM HIGH AS SINGLE
'****PROGRAM****
GOSUB DATAENTRY:
GOSUB CALCGRADES:
GOSUB STUDENTREPORT:
END
'****SUB-ROUTINES****
DATAENTRY:
CLS
COLOR , 0
CLS
PRINT
COLOR 14

PRINT "********************************************************************************"
PRINT TAB(31); "DATA ENTRY SCREEN"
PRINT "********************************************************************************"
PRINT
PRINT TAB(8); "Please enter as you would like it to appear on student report"
PRINT
INPUT " ENTER INSTRUCTOR'S FULL NAME: ", TEACH$
INPUT " ENTER COURSE NAME: ", CLASS$
INPUT " ENTER STUDENT'S FULL NAME: ", STU$
INPUT " ENTER STUDENT'S TEST SCORE #1: ", GRADE(1)
INPUT " ENTER STUDENT'S TEST SCORE #2: ", GRADE(2)
INPUT " ENTER STUDENT'S TEST SCORE #3: ", GRADE(3)
INPUT " ENTER STUDENT'S TEST SCORE #4: ", GRADE(4)
INPUT " ENTER STUDENT'S TEST SCORE #5: ", GRADE(5)
RETURN

CALCGRADES:
HIGH = GRADE(G)
LOW = GRADE(G)
FOR GRADE = 1 TO 5
IF GRADE(G) > HIGH THEN
HIGH = GRADE(G)
END IF
IF GRADE(G) < LOW THEN
LOW = GRADE(G)
END IF
NEXT G
TOTAL = GRADE(1) + GRADE(2) + GRADE(3) + GRADE(4) + GRADE(5)
AVG = TOTAL / 5
NEWAVG = (TOTAL - LOW) / 4
RETURN

STUDENTREPORT:
CLS
COLOR , 6
CLS
PRINT
COLOR 15
H1$ = "Grade report for: "
H2$ = "Prepared on: "
H3$ = "Class Name: "
H4$ = "Instructor: "
H5$ = "-------------------------------------------"
H6$ = "Test 1: "
H7$ = "Test 2: "
H8$ = "Test 3: "
H9$ = "Test 4: "
H10$ = "Test 5: "
H11$ = "Average: "
H12$ = "Low Score: "
H13$ = "High Score: "
H14$ = "New Average with lowest test score dropped: "

PRINT TAB(22); H1$; STU
PRINT TAB(22); H2$; DATE$
PRINT TAB(20); H5$
PRINT
PRINT
PRINT
PRINT
PRINT TAB(10); H3$, CLASS$
PRINT TAB(10); H4$, TEACH$
PRINT
PRINT
PRINT TAB(10); H6$; GRADE(1)
PRINT TAB(10); H7$; GRADE(2)
PRINT TAB(10); H8$; GRADE(3)
PRINT TAB(10); H9$; GRADE(4)
PRINT TAB(10); H10$; GRADE(5)
PRINT TAB(10); "------------"
PRINT TAB(10); H11$; AVG
PRINT
PRINT TAB(10); H12$; LOW
PRINT TAB(10); H13$; HIGH
PRINT
PRINT TAB(10); H14$; NEWAVG
RETURN
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 40
Reputation: Buff is an unknown quantity at this point 
Solved Threads: 0
Buff Buff is offline Offline
Light Poster

Re: Need help with Arrays

 
0
  #2
Nov 2nd, 2004
Originally Posted by Katie G
Newbie to QB - I have an assignment to create a grade sheet for one student. Must list name, instructor, class, test grades 1 through 5, average, low grade, high grade and new average with lowest grade dropped. I am so confused about arrays. I am using examples from class but I can't seem to get it to work. Anyone's help is appreciated. Here is what I have so far:

'****DIMENSION STATEMENTS****
DIM STU AS STRING
DIM CLASS AS STRING
DIM TEACH AS STRING
DIM GRADE (1 TO 5) AS INTEGER
DIM AVG AS SINGLE
DIM NEWAVG AS SINGLE
DIM LOW AS SINGLE
DIM HIGH AS SINGLE
'****PROGRAM****
GOSUB DATAENTRY:
GOSUB CALCGRADES:
GOSUB STUDENTREPORT:
END
'****SUB-ROUTINES****
DATAENTRY:
CLS
COLOR , 0
CLS
PRINT
COLOR 14

PRINT "********************************************************************************"
PRINT TAB(31); "DATA ENTRY SCREEN"
PRINT "********************************************************************************"
PRINT
PRINT TAB(8); "Please enter as you would like it to appear on student report"
PRINT
INPUT " ENTER INSTRUCTOR'S FULL NAME: ", TEACH$
INPUT " ENTER COURSE NAME: ", CLASS$
INPUT " ENTER STUDENT'S FULL NAME: ", STU$
INPUT " ENTER STUDENT'S TEST SCORE #1: ", GRADE(1)
INPUT " ENTER STUDENT'S TEST SCORE #2: ", GRADE(2)
INPUT " ENTER STUDENT'S TEST SCORE #3: ", GRADE(3)
INPUT " ENTER STUDENT'S TEST SCORE #4: ", GRADE(4)
INPUT " ENTER STUDENT'S TEST SCORE #5: ", GRADE(5)
RETURN

CALCGRADES:
HIGH = GRADE(G)
LOW = GRADE(G)
FOR GRADE = 1 TO 5
IF GRADE(G) > HIGH THEN
HIGH = GRADE(G)
END IF
IF GRADE(G) < LOW THEN
LOW = GRADE(G)
END IF
NEXT G
TOTAL = GRADE(1) + GRADE(2) + GRADE(3) + GRADE(4) + GRADE(5)
AVG = TOTAL / 5
NEWAVG = (TOTAL - LOW) / 4
RETURN

STUDENTREPORT:
CLS
COLOR , 6
CLS
PRINT
COLOR 15
H1$ = "Grade report for: "
H2$ = "Prepared on: "
H3$ = "Class Name: "
H4$ = "Instructor: "
H5$ = "-------------------------------------------"
H6$ = "Test 1: "
H7$ = "Test 2: "
H8$ = "Test 3: "
H9$ = "Test 4: "
H10$ = "Test 5: "
H11$ = "Average: "
H12$ = "Low Score: "
H13$ = "High Score: "
H14$ = "New Average with lowest test score dropped: "

PRINT TAB(22); H1$; STU
PRINT TAB(22); H2$; DATE$
PRINT TAB(20); H5$
PRINT
PRINT
PRINT
PRINT
PRINT TAB(10); H3$, CLASS$
PRINT TAB(10); H4$, TEACH$
PRINT
PRINT
PRINT TAB(10); H6$; GRADE(1)
PRINT TAB(10); H7$; GRADE(2)
PRINT TAB(10); H8$; GRADE(3)
PRINT TAB(10); H9$; GRADE(4)
PRINT TAB(10); H10$; GRADE(5)
PRINT TAB(10); "------------"
PRINT TAB(10); H11$; AVG
PRINT
PRINT TAB(10); H12$; LOW
PRINT TAB(10); H13$; HIGH
PRINT
PRINT TAB(10); H14$; NEWAVG
RETURN
--------------------------------------------------------------

ok you have mixed up your array subscripts where the program should not work

HIGH = 0 'GRADE(G)
LOW = 0 'GRADE(G)
TOTAL=0
FOR G = 1 TO 5
IF GRADE(G) > HIGH THEN
HIGH = GRADE(G)
END IF
IF GRADE(G) < LOW THEN
LOW = GRADE(G)
END IF
NEXT G

That should make your high and low come out ok.
When using a for loop the subscript must be the same as you start with
and NOT the name of a variable.
i.e. GRADE(GRADE) will not work and it's bad practice anyway because it's
confusing.

Otherwise it looks like it should work fine though I havent run it to see
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 1
Reputation: tucson-az is an unknown quantity at this point 
Solved Threads: 0
tucson-az tucson-az is offline Offline
Newbie Poster

Re: Need help with Arrays

 
0
  #3
Apr 3rd, 2009
Watson elementary school contain 30 classrooms numbered 1 through 30. Each classroom can contain any number of student up to 35. Each student takes an achievement test at the end of the school year and receive a score from 0 through 100. Write a program that accepts data for each student in the school studentID, classroom number, and score on the achievement test
Design a program that lists the total point scored for each of the 30 classroom

Modify exercise so that each classrooms average of the test score prints, rather than each classroom's total
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC