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
4. Create Records

Output:
1. Student
(string)
2. Test1, Test2, Test3 (Integer 1-100)
(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:

Integer
1-300

3. DisplayResult

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

Type: Integer
Range: 1-300

Name: Student (Display)
Type: String
Range:

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

Type: Integer
Range: 1-300

CHAPTER 8 PROGRAMMING PROBLEMS

MainModule
Declare Student as string
Declare Test1 as integer
Declare Test2 as integer
Declare Test3 as integer

Call InputData
Call DisplayResults
End MainModule

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

CHAPTER 8 PROGRAMMING PROBLEMS

Input Test2
Input Test3
End While
End InputData

CalculateTotal
Total Score = Test Score1 + Test Score2 + Test Score3
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

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

Type: Integer
Range: 1-300

CHAPTER 8 PROGRAMMING PROBLEMS

DisplayResults