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

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

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

This article has been dead for over six months. Start a new discussion instead.