IT/210
Chapter 8 Programming Problems
For each of the following problems, use the top-down modular approach and pseudocode to design a suitable program to solve it. 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(interger), test2 (interger), test3 (interger). In this file, all test scores should be set equal to 0.
Analysis
Process 1. Display input student name and test scores screen 2. Prompt for student name 3. Prompt scores 4. Perform calculations 5. Provide student names, scores and total
Input
1. Student Name 2. Test scores
Output
1. Display student name, scores, and total.
Declare Studentname as string
Declare Test1 as interger
Declare Test2 as interger
Declare Test3 as interger
Set Test1, Test2, Test3 = 0
Open “Grades” for output as TestScores
Write “Please input the students name”
Input Studentname
Write “Please input student scores.”
Input Test1, Test2, Test3
Write “Please input ZZZ for students name when done.”
While Studentname does not equal “ZZZ” Write TestScores, Studentname, Test1, Test2, Test3 Write “Please input the students name”
Input Studentname
Write “Please input student scores.”
Input Test1, Test2, Test3
Write “Please input ZZZ for students name when done.”
End While
Close TestScores
2. Display the contents of the file GRADES created in problem 1. Each student’s record should apper on a seprate 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
Declare Sum as integer
Open “GRADES” for input as Test Scores
While Not (TestScores)
Input TestScores, studentname, Test1, Test2, Test3
Sum = Test1 + Test2 + Test3
Write Studentname, Test1, Test2, Test3, Sumn
End while
Close