Introduction to Computer Science I by James Tam | Return to the course web page |
For this assignment you are to write a Pascal program that allows a person to track the courses that he or she has taken. In the full version of the assignment your program will read the initial course information from a file called 'courses.dat' into an array of records. The array must be large enough to read in the information for all the courses in the input file plus it should allow the user to insert a few additional courses (just make the array size reasonable, say 100 elements). The user can perform all the common list management functions, such as removing courses from the list or inserting new courses into the list. When the person has finished with the program, he or she can then save the updated information back to the original file and reload that information again.
Each course will be described by four fields with each field residing on a separate line in the input file:
Your program reads the information from the input file 'courses.dat' into the array. (Although the grades field is an integer your program must be able to real in the real number grade points). The contents of that array can be displayed onscreen with write's and writeln statements with each course separated by a line of stars. To prevent the output from scrolling off the screen your program should 'pause' the display of courses every so often (say after displaying every half dozen or dozen courses) while it waits for a response from the user to tell it to continue (e.g., 'Hit enter to continue'). The output must be displayed in a neat and legible format that clearly labels each field of each course (try running the sample executable for an example of how your output could look). Also the grade must be shown in the form of real number (one decimal place) GPA: A = 4.0, A- = 3.7, B+ = 3.3, B = 3.0, B- = 2.7, C+ = 2.3, C = 2.0, C- = 1.7, D+ 1.3, D = 1.0, F = 0.0. Finally your program must be able to write the information for the courses back to a file. The grades must be written to the file in the same real number format as the input file. The user should be able to specify the name of the input and output file as the program runs. The line of stars that separated each course when they were displayed onscreen should not be written to this file but an empty line should be written instead (i.e., the format of the output file should be the same as the courses.dat input file). Similar to previous assignments, your program has menu driven interface. The basic program should display a menu similar to the one shown below:
Course Manager: Menu options
(d)isplay courses
(l)oad the course information from a file
(s)ave the information about courses to a file
(q)uit the program
You should add additional menu options as you implement the extra features that are listed below. Also when your program detects when the input file is empty it should display an appropriate status message. Finally your program should prevent overflow of the array (trying to add more elements to an array that is already full). For this version, your program will need to perform this check as the information for the courses is read in from file. If you implement the 'insert' feature then your program will have to perform this check at that point too.
Missing the features listed above: You have the potential to receive a maximum grade of 'C+' if you implement all of the above features. If features are missed or improperly implemented then your mark may be reduced by a letter step for each feature that is missed (down to a minimum grade of a 'D' assuming of course that it actually compiles):
Completion of each of these extra features will result in the increase of a "one step" to your grade e.g., 'C+' to 'B-'. Unless there is a compelling reason to do otherwise you may complete as many of the features below as you wish in whatever combination that you desire. Successful completion of all six features will make you eligible for an 'A+'. (You must also fulfill style requirements as well as the general submission assignment requirements
Feature one (Arrange the list of courses according to the course name and number):
To receive credit for this feature you need to sort the list of courses by the course name and number (i.e., the program will order courses first according the ASCII value of the course names and when the course names are identical it will perform the sort according the ASCII values of the course number). To do this you need to implement a sort procedure that compares the entire 'course name identifier' field. Unlike the way that you compared the character arrays in the sixth assignment you can compare the entire field/string (i.e., if (string1 > string 2) and you do not have to perform a character-by-character comparison (if string1[1] > string[2]).
Feature two (Find additional details about a course):
The user of the program can type a course identifier (case sensitive for the name) to find additional information about that course . If the course is not in the list, then your program should indicate that the course could not be found under that identifier. If the course is in the list, then your program will display additional details about that course (all the fields will be displayed onscreen).
Feature three (Present all courses that meet a certain criteria):
The user can type a real number grade point (e.g., 4.0) and your program will display all the courses for which such a grade was awarded.
Feature four (Insert a new course):
When this feature is selected by the user, he or she will prompted to enter in information for all the fields of the new course. If the course doesn't already exist in the list (as determined by the course identifier field) and there is room in the array, the new course will then be added into it's proper place in the list (according the ASCII value of the course identifier field). All the courses that follow will be shifted 'down' the list. If the course already exists in the list or if the list is already full then a suitable error message will be displayed to the user. A simple error check that the grade is one of the valid integer values should be performed. All of these requirements must be met in order to get credit for this feature.
Feature five (Remove a course from the list):
When this feature is invoked the user must type in the course identifier to indicate which course that he or she wishes to remove from the list. When the list is displayed, no information about the deleted course should be displayed - not even blank spaces. You can implement this feature by shifting the array elements that follow the element to be deleted 'up'. To get credit for this feature your program must not allow the user to remove elements from the array when it is already empty.
Feature six (Write an enhanced Save feature)
In order to get credit for this feature, the program must be able to re-read information from the output file. When the user of the program opts to save the updated information your program will still ask for the name of the output file. The difference is that you program now must be able to write the updated course information back to the original data file AND it must be able reload the course information from this same file. It is the last point that is the key to this feature. In the previous versions of your program it could write the updated information to a file but the program did not have to be able to read the updated information back into the program. If there were small discrepancies between the input and output file that weren't visible to the human eye you could still get full credit for your work. In this case these discrepancies will cause problems when your program tries to re-read the updated information (the key is to write it back to file in a format that is identical to the format of the input file). Your TA will be checking if it can: 1) read the information 2) write the modified information to a file 3) re-read the modified information back into the program.
Note: The user should not be able to invoke features one, two, three, five and six when the list is empty. If the operation is invoked then an error message should be displayed. As previously mentioned, feature five should not be invoke able when the list is empty.
You can run a sample executable called 'courses' which can be found in the UNIX directory: /home/231/assignments/assignment8. In addition there is a data file that your TA's will use when they are marking your program called 'courses.dat'.
1 What does and doesn't constitute a sufficient amount of time and effort? It's a judgment call on the part of your marker. More often than not if you put in a reasonable amount of effort into your assignment and for some reason you just couldn't get it to work then you will receive some credit for your work. An example of when you wouldn't receive credit is when you simply handed someone else's work. This latter case assumes that you properly cited the other person's work, if you didn't cite your source and tried to claim that it was your own work then it would be an example of academic misconduct (cheating).