It210 Week 7 Checkpoint Programming Problems

Only available on StudyMode
  • Topic: Andrew Martin, Test score, Test
  • Pages : 2 (341 words )
  • Download(s) : 469
  • Published : July 23, 2012
Open Document
Text Preview
Week 7 Checkpoint Programming Problems 1 and 2

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 (integer), test2 (integer), test3 (integer). In this file, all test scores should be set equal to 0. Analysis

Processes
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 integer
Declare Test2 as integer
Declare Test3 as integer

Open “GRADES” For Output As TestScores
Set Test1, Test2, Test3 = 0
Write “Please input the students name and test scores.” Write “Please input ZZZ for students name when done.” Input StudentName, Test1, Test2, Test3
While StudentName <> “ZZZ”
Write TestScores, StudentName, Test1, Test2, Test3 Write “Please input students name and test scores.” Write “Please input ZZZ for students name when finished.” Input StudentName, Test1, Test2, Test3

End While
Close TestScores

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

Declare Sum as integer

Open “GRADES” For Input As TestScores
While Not (TestScores)
Read TestScores, StudentName, Test1, Test2, Test3
Add Test1 + Test2 + Test3 = Sum
Write StudentName, “ “, Test1, Test2, Test3, Sum End While
Close TestScores

In this code I...
tracking img