Running head

Running head: CHAPTER 8 PROGRAMMING PROBLEMS

Chapter 8 Programming Problems

Dale Lappin

IT210

08/17/2012

Daniel Reddy

CHAPTER 8 PROGRAMMING PROBLEMS

Chapter 8 Programming Problems

a) Input names of students from the user, terminated by ”ZZZ”,0,0,0, and create a data file
grades with records of the following form:
Student (String), test1 (Integer), test2 (Integer), test3 (Integer)

Analysis

Input:
1.
2.
3.
4.

Process:
1. Get user input
2. Create GRADES
3. Calculate Grade_Total
4. Create Records

Output:
1. Student
(string)
2. Test1, Test2, Test3 (Integer 1-100)
3. Grade_Total
(Integer 1-300)

Input
Student
String

Name:
Type:
Range:
Name:
Type:
Range:

Test1
Integer
1-100

Name: Test2
Type: Integer
Range: 1 -100

Name:
Type:
Range:
Name:
Type:
Range:

Test3
Integer
1 -100
Student
String

Student
Test1
Test2
Test3

(string)
(Integer 1-100)
(Integer 1-100)
(Integer 0-100)

Processes
1.InputData

2.CalculateTotal

Output
Student
String

Name:
Type:
Range:
Name:
Type:
Range:

Grade_Total
Integer
1-300

3. DisplayResult

Name: Test1, Test2, Test3
Type: Integer
Range:1-100

Name: Grade_Total
Type: Integer
Range: 1-300

Name: Student (Display)
Type: String
Range:

Name: Test1, Test2, Test3
(Display)
Type: Integer
Range: 1-100

Name: Grade_Total (Display)
Type: Integer
Range: 1-300

CHAPTER 8 PROGRAMMING PROBLEMS

MainModule
Open GRADES
Declare Student as string
Declare Test1 as integer
Declare Test2 as integer
Declare Test3 as integer
Declare Grade_Total as integer
Close GRADES

Call InputData
Call CalculateGradeTotal
Call DisplayResults
End MainModule

InputData
Display “Enter Student’s name, ZZZ to quit”
Input Student
While Student < > “ZZZ”
Write Student to GRADES
Input Test1
Write“Test1” to GRADES

CHAPTER 8 PROGRAMMING PROBLEMS

Input Test2
Write “Test2” to GRADES
Input Test3
Write “Test3” to GRADES
Write newline to GRADES
End While
End InputData

CalculateTotal
Read Test1 from GRADES
Read Test2 from GRADES
Read Test3 from GRADES
Declare Grade_Total as Integer
Total Score = Test Score1 + Test Score2 + Test Score3
Write “Grade_Total” to GRADES
End CalculateTotal

b) Display the contents of the file grades created in Part a. 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 as follows:

R. Abrams 76 84 82 242

Input
Name: Student
Type: String
Range:

Name: Test1, Test2, Test3
Type: Integer
Range:1-100

Name: Grade_Total
Type: Integer
Range: 1-300

Processes
3. DisplayResult

Output
Name: Student (Display)
Type: String
Range:

Name: Test1, Test2, Test3
(Display)
Type: Integer
Range: 1-100

Name: Grade_Total (Display)
Type: Integer
Range: 1-300

CHAPTER 8 PROGRAMMING PROBLEMS

DisplayResults
Read Student from GRADES
Read Test1 from GRADES
Read Test2 from GRADES
Read Test3 from GRADES
Read Grade_Total from GRADES
Display Student “test scores” Test1, Test2, Test3 “=” Grade_Total
Write newline to Grades
End DisplayResults

Leave a Reply