Data Requirements Tables
Main program and then functions, keeping each as simple as possible
Main Program
Determining key data structures to model data …(while designing structure
of program)
counter – count of number of records processed (integer)
student_record – struct for storing student data (what information
do we need about each student?)
(type
student_record_type)
ssno (string) – social security number
lname (string) – last name
fname (string) – first name
exams (array [3] of integers) – for storing up to 3
exam scores
homework (integer) – homework score
quizzes (array [10] of integers) – for storing up to
ten quiz
scores
total_score – …
letter_grade – …
· Function and Function Interfaces (Specifications)
Process_id – Specification
Function to process student id – read and store student ssno,
last_name
and first_name
(extracts data from input stream and stores in local variables)
Returns a flag indicating if an error occurred
(How is end-of-file flag communicated from one function to
another?)
Arguments:
ins – (INOUT, istream) input stream from which data
is read
student_record - (OUT, student_record_type) used to
store ssno,
last_name,
first_name as read
After components selected and relationships understood you can go back to each component and, starting with the interfaces or specifications, begin to work on the implementation.
Process_id – Implementation:
In this function we make a decision to read all data into local
variables
and then store the contents of the local variables into the struct argument
after all input is read.
Top level algorithm
Process_scores – Specification
Function to process student scores: extract, validate, and store
Extracts scores from input stream, validates each, determines kind
(exam, homework, quiz) and stores
(How do you handle end-of-file and/or end_of_line flags here?)
Arguments:
ins – (INOUT - istream) input stream from which data
is read
student_record - (INOUT - student_record_type) used
to store ssno,
last_name, and first_name
After components selected and relationships understood you can go back to each component and, starting with the interfaces or specifications, begin to work on the implementation.
Process_scores – Implementation:
In this function we make a decision to read all data into local
variables
and then store the contents of the local variables into the struct argument
after all input is read and validated (and struct field is determined).
We have to process each score_code and score_value pair separately.
Here
the local variables are critical. They were not so critical in Process_id.
Top level algorithm:
We need a loop to process one score_code and score_value at a time
(until what?? – marker needed?)
How do we read a score_code and score_value pair? How do we determine where to store homework, quiz, or exam score? How do we know if we end up with too many homework, exam or quiz scores? Need several local variables to help. What are they, and how will they be used?
Validation to be performed for each score code-value pair: