1. Input names of students from the user, terminated by ZZZ, and
create a data file GRADES with records of the form:
student (string), test1 (integer), test2 (integer), test3 (integer)
In this file, all test scores should be set equal to 0.
2. Display the contents of the file GRADES created in Problem 1.
Each student’s record should appear on a separate line and include
the total score (the sum of the three tests) for that student. For
example, a line of output might be:
R. Abrams 76 84 82 242
Also, As long as the user does not enter "ZZZ" new records are created and automatically added, and when reading the file all records will be displayed, correct?
If someone could take a look at this and critique, it would be appreciated.
Process
Get Student Name, Test Score
Create New File “Grades”
Calculate Grade Total
Input
Student Name
Test Scores
Output
Read Grade File, “Student”, “Test1", "Test2”, "Test3", “Total”
Main Module
Declare Student as String
Declare Test1, Test2, Test3, as Integer
While Student <> “ZZZ”
Call Student Grades
Call Calculate Grades
Call Display Grades
End While
End Program
Student Grades
Open “Grades” For Output as NewFile
Write “Enter the student and three test scores separated by commas please.”
Write “Enter “ZZZ” when done
Input Student, Test1, Test2, Test3
While Student <> “ZZZ”
Set Test = 0
Write NewFile, Student, Test1, Test2, Test3
Write “Enter the students name and three test scores.”
Write “Enter “ZZZ” when done.”
Input Student, Test1, Test2, Test3
End While
End Student Grades
Calculate Grades
Declare Total as Integer
Set Total = Test1 + Test2 + Test3
Close NewFile
End Calculate Grades
Display File
Open “Grades” For Output as GradeFile
Read GradeFile, “Student”, “Test1”, “Test2”, “Test3”, “Total”
End Display File