This program calculates and prints a student grade average from five individual scores. It prompts the user to enter a date, a student name, and five numeric scores via INPUT statements, then echoes each entry to the printer with LPRINT. After all scores are collected, it computes the total with a single LET statement and divides by five to produce an average, which is printed in a summary report. The program loops continuously via GOTO 20, allowing multiple students to be processed in sequence, and uses CLEAR before each new iteration to free string storage.
Program Analysis
Program Structure
The program is organised into a clear linear sequence with a continuous loop. Line numbering uses large, irregular gaps (e.g. jumping from 32 to 2500, then incrementing by 1 for related sub-steps), which is a common informal style rather than a deliberate design. The overall flow is:
- Lines 10–32: Print header and collect/print the date.
- Lines 2500–4002: Collect student name and five scores, echoing each to the printer via
LPRINT. - Lines 5000–6000: Spacing and summary header.
- Lines 7000–7001: Compute total (
E) and average (A). - Lines 8000–8020: Print average, clear memory, and loop back to line 20.
- Lines 8900–9000: Utility lines for saving and listing.
Input and Output Strategy
Every data item entered via INPUT is immediately echoed to the printer with a paired LPRINT statement. This mirrors the entered data onto paper as a record, since the screen display alone would be lost on the next iteration. The date is only collected once at line 31 and printed once at line 32, but the loop at line 8020 returns to line 20, meaning the date header is re-printed to the printer for every student — potentially cluttering the printout if many students are processed.
Calculation
The average is computed across exactly five scores using two LET statements at lines 7000–7001. The intermediate sum variable E is retained but only A (the average) is printed. There is no rounding applied; the result will be printed with full floating-point precision as provided by the runtime.
Variable Summary
| Variable | Purpose |
|---|---|
D$ | Date string entered by user |
N$ | Student name |
E1–E5 | Individual scores (numeric) |
E | Sum of all five scores |
A | Calculated average |
Notable Techniques and Idioms
CLEARat line 8010 is used before looping. This resets all variables and frees string storage, which is a standard housekeeping practice in looping programs that repeatedly assign string variables likeN$andD$.- The blank
PRINTstatements at lines 2650, 2651, 5000, and 5001 produce empty lines for visual spacing on screen. - Lines 8900 (
SAVE) and 9000 (LIST) are utility lines intended to be run manually by the user and are never reached by the normal program flow.
Bugs and Anomalies
- The loop returns to line 20 rather than line 2500, so the “STUDENT GRADE AVERAGE” header and the date prompt are re-issued on every iteration. The date would need to be re-entered for each student, which is likely unintentional. A loop back to line 2500 would be more practical for batch use.
- There is no validation of score inputs; non-numeric entries would cause an error.
- The number of scores is hardcoded to exactly five with no facility for fewer scores or an absent result.
Content
Source Code
10 REM STUDENT GRADE AVERAGE
20 LPRINT "STUDENT GRADE AVERAGE"
30 PRINT "ENTER DATE"
31 INPUT D$
32 LPRINT D$
\n2500 PRINT "ENTER STUDENT NAME"
\n2600 INPUT N$
\n2601 LPRINT N$
\n2650 PRINT
\n2651 PRINT
\n2700 PRINT "ENTER SCORE 1"
\n2701 INPUT E1
\n2702 LPRINT E1
\n2800 PRINT "ENTER SCORE 2"
\n2801 INPUT E2
\n2802 LPRINT E2
\n2900 PRINT "ENTER SCORE 3"
\n2901 INPUT E3
\n2902 LPRINT E3
\n3000 PRINT "ENTER SCORE 4"
\n3001 INPUT E4
\n3002 LPRINT E4
\n4000 PRINT "ENTER SCORE 5"
\n4001 INPUT E5
\n4002 LPRINT E5
\n5000 PRINT
\n5001 PRINT
\n6000 LPRINT "SUMMARY REPORT FOR ";N$
\n7000 LET E=E1+E2+E3+E4+E5
\n7001 LET A=E/5
\n8000 LPRINT "AVERAGE SCORE=";A
\n8010 CLEAR
\n8020 GOTO 20
\n8900 SAVE "1010%7"
\n9000 LIST
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
