CS223 Machine Problem 4

Software Laboratory: Spring 1998
University of Illinois, Urbana-Champaign
 
 
Due Date Wednesday,  Apr  1st, at 5.00 PM
Readings Lectures 1-9,  Chapter 1-9 of Deitel & Deitel,  
Labs 1-9
Files to submit Submit only the files  Student.h,  
Student.C, mp4.C 
 
 

Preliminaries

To do this MP, you must have read and understood the material covered in the first  nine lectures, and the first nine chapters of the textbook by Deitel and Deitel.  More specifically, this MP  focusses on  the material covered in lectures 8 and 9.   Make sure you are comfortable working with linked lists. Lecture 8 and lab 8 cover this material. Also work with the debugger ( gdb) and familiarize yourself with commands that set breakpoints, print a variable and so on. Some frequently used commands for debugging purposes are {where , break, step, continue, skip,print }. Use the help to know how to use them. Also,  please read the specification thoroughly before you begin coding.

Although you have the spring break to do the MP, please start early so that you can clarify all your doubts before the break.  I will not be able to hold office hours or respond to the newsgroup/email during the spring break. All office hours  will be held before the break begins.

Overview

In this MP,  you will learn to use inheritance and information hiding  in C++ to create a simple gradesheet for students in a course. The  course has students belonging to different backgrounds.  Some of them have already mastered some of the material in the course while most of the others have practically no background in the material taught.  Hence it is necessary to have a different  grading criteria  for these  two extreme  sets of students.

For the purposes of this assignment, we classify  these students into two types:  ProficiencyStudent and RegularStudent.  A  RegularStudent  is graded based on his/her score in 3 MPs. A  ProficiencyStudent is graded based on his/her score on two proficiency exams. The final gradesheet has to appear sorted on the final score of each student, for both classes of students.

The Machine Problem

This section  will describe the machine problem in  detail.  First we describe the input format for the program,  the expected format  of the output , followed by a description of the classes you need to design.

Input Format

Information  about each student in the course is stored in a file.  So you will read in the input for the students from a file. Each line of the input file appears in ONE of the following formats:

ssno  proficiencyLevel score1 score2 score3  

 OR

ssno  proficiencyLevel score1 score2
 ssno                                    - Student id, a simple integer
 proficiencyLevel                - proficiency level of the student :
                                                         0 indicates  a  RegularStudent ,
                                                         1 indicates a  ProficiencyStudent
 score1,score2,score3       - scores on the 3 MPs for a  RegularStudent
 score1,score2                    - scores on the two exams for a  ProficiencyStudent

 A sample input file looks as follows:  
123     0    90.5  60.5  75.0
10       1    98.0  98.0
100     0    0.0    55.0  60.0
1000   1    95.0  97.0

This indicates that 123 is the id of a RegularStudent with scores 90.5, 60.5, 75.0 on the 3 MPs respectively while 10 is the id of a ProficiencyStudent who scored 98.0  on both the proficiency exams. The other two inputs are similar.  

Output Format

Your output will list the regular students sorted in descending order on their final scores followed by the proficiency  students  again sorted in descending order on their final scores. You will need to output the id , final score, and the grade for each student. Computation of the final score and assignment of grades will be described in a later section. Make sure to separate the two lists by a BLANK LINE. A sample output for the above input would be as follows :
 
123            75.3   B
100            38.3   D
 
10              98.0   A
1000          96.0   A

Implementation 

To help you get started, we will provide you the minimal interfaces for the classes you need to design. You will provide the actual  implementation.  

Students.h

This header file defines the base class Student, and its two subclasses, RegularStudent and ProficiencyStudent.

The  Student class has the following members:
 
ssno            :     student id
finalScore   :     final percentage which forms the basis for grading
grade           :     final grade of the student. Can be one of 'A','B','C','D',or 'F'.
printGrade():     prints the id, final score and grade of a student  as indicated earlier in the output format
 
All the data members specified above are private.  As such you will need to define appropriate access functions to  read and write them if required.  These access functions should have as much restricted scope as possible which  means that any unnecessary use of the public scope will be penalized. This is to enforce the  use of  the information hiding feature of C++.

The RegularStudent class and  ProficiencyStudent  class  are publicly derived subclasses of Student. In addition to inheriting the members of  Student, each has the following members  of its own.  
computeGrade()         - a function that computes the grade
computeFinalScore() - a method that computes the final score
 
For a  RegularStudent, the final score is the average of the 3 MP scores. For a ProficiencyStudent, the final score is  the average of the 2 exam scores. The grade allocation for a RegularStudent  is as follows:

A:  85.0  < finalScore <= 100.0
B:  65.0  < finalScore <= 85.0
C: 45.0  < finalScore <= 65.0
D: 30.0  < finalScore <= 45.0
F:  finalScore <= 30.0
 
The grade allocation for a ProficiencyStudent is as follows:

A: 90.0 < finalScore <= 100.0
B: 80.0 < finalScore <= 90.0
C: 70.0 < finalScore <= 80.0
D: 60.0 < finalScore <= 70.0
F:  finalScore <= 60.0
 
Of course, you need to define the constructors for the classes.  While designing the derived classes, you should remember that the derived classes cannot access any private member of its base class directly.  Thats why you need the access functions in the base class. However,  any public or protected member of the base class can be directly accessed within the derived classes.  

Student Database

The  above classes represent a single student record. However,  the course  has  many students. So we need to  have a way to store multiple student records.  In order to do this, we will use a linked list  structure.  We will have  two separate linked lists , one for the regular students and the other for the proficient students.  Design of the linked  list  will be left to you.  A good starting point would be to work through the examples in lecture 8 and see how they  can be applied to this MP.  Again,  remember that data members should almost always be private and any unnecessary  use of the public scope for methods will be penalized.

Student.C

You must separate the implementation from the interface. This means that the definitions of all the class methods must appear in a file called  Student.C. Also,  the above description does not  completely specify the prototypes of the member functions. It is your responsibility to choose the appropriate parameters and return type for the functions, in accordance with the specification.  

mp4.C

This file defines the main() function.  You will read in the input file  and add each student to the appropriate linked list. Finally,  you will need to  print a sorted output of each list in the format indicated earlier. 
 

Testing and  Handin

First, create a subdirectory in your home directory, and call it cs223mp4/.

mkdir cs223mp4

Change into this directory, with

cd cs223mp4

You have been provided with several test cases.  (There is no wrap.C, since you will define main() yourself.)
You should copy the files in the ~cs223/src/mp4/test/ directory to your work directory

cp ~cs223/src/mp4/test/*  ./

The TA solution is available as ~cs223/bin/ta-mp4.  You can execute the program by giving the command:

~cs223/bin/ta-mp4

at the Unix prompt. Play around with this program to get a sense of what sort of classes and member functions you have to write.

To compile your code give the command

% make
 
It will produce the executable file a.out.To run the program, give the command a.out at the unix prompt.

% a.out < infile

will redirect input from infile.

To test your program against the test cases, give the command

% make testQ

where Q=1, ..., 6

% make tests

will cause all the tests to execute.

To handin your program, use the command

% make handin

Note that you must give the above handin command only from the sparc-machines in the Sparc-labs (1235/1245 DCL).
 

Grading Policy

Your solution should compile correctly. Furthermore, output from all the test cases should match the standard output given.  You should also write your program so that it adheres to the specification.

                                  Approximate grading criteria
 
Correct compilation  25 marks
Each of the 6 test cases  5 marks
Proper coding style  10 marks 
 
Proper Design of classes   20 marks
Linked List Implementation  15 marks 

There is an automatic 24 hours extension beyond the Wednesday 5 PM deadline. No penalty will occur for submission during this extension. However, no late assignments beyond this extension will be accepted.
 



Last revised: Mar 11th, 1998