CIS 501
Assignment 1 - Spring 2003
Documentation and Hints


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

  1. extract ssno (validate?) and store in ssno (string)
  2. extract last name (validate?) and store in last_name (string)
  3. extract first name (validate?) and store in first_name (string)
Local Variables:
(indicated above in 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?)

  1. extract score_code (validate?) (type? store? How do we use it?)
  2. extract score_value (validate?) (type?, store – how do we know where?)

Local Variables:
(to be filled in by you)

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:

Determine_grade – Specification and Implementation to be done in class and filled in by you. You MUST implement this as a module as described in the text book. You must use a lookup table (described in class and you need functions to (1) initialize the data stores in the class, (2) look up a score and retrieve the corresponding letter grade, and (3) display the contents of the table (at least during debugging).