Student Grade Average

This file is part of and Timex Sinclair Public Domain Library Tape 1002. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Teaching

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:

  1. Lines 10–32: Print header and collect/print the date.
  2. Lines 2500–4002: Collect student name and five scores, echoing each to the printer via LPRINT.
  3. Lines 5000–6000: Spacing and summary header.
  4. Lines 7000–7001: Compute total (E) and average (A).
  5. Lines 8000–8020: Print average, clear memory, and loop back to line 20.
  6. 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

VariablePurpose
D$Date string entered by user
N$Student name
E1E5Individual scores (numeric)
ESum of all five scores
ACalculated average

Notable Techniques and Idioms

  • CLEAR at 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 like N$ and D$.
  • The blank PRINT statements 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

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Source Code

  10 REM STUDENT GRADE AVERAGE
  20 LPRINT "STUDENT GRADE AVERAGE"
  30 PRINT "ENTER DATE"
  31 INPUT D$
  32 LPRINT D$
 2500 PRINT "ENTER STUDENT NAME"
 2600 INPUT N$
 2601 LPRINT N$
 2650 PRINT 
 2651 PRINT 
 2700 PRINT "ENTER SCORE 1"
 2701 INPUT E1
 2702 LPRINT E1
 2800 PRINT "ENTER SCORE 2"
 2801 INPUT E2
 2802 LPRINT E2
 2900 PRINT "ENTER SCORE 3"
 2901 INPUT E3
 2902 LPRINT E3
 3000 PRINT "ENTER SCORE 4"
 3001 INPUT E4
 3002 LPRINT E4
 4000 PRINT "ENTER SCORE 5"
 4001 INPUT E5
 4002 LPRINT E5
 5000 PRINT 
 5001 PRINT 
 6000 LPRINT "SUMMARY REPORT FOR ";N$
 7000 LET E=E1+E2+E3+E4+E5
 7001 LET A=E/5
 8000 LPRINT "AVERAGE SCORE=";A
 8010 CLEAR 
 8020 GOTO 20
 8900 SAVE "1010%7"
 9000 LIST 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top