Introduction to Computer Science II by James Tam | Return to the course web page |
The program should allow the user to run basic list operations: initializing the list, displaying the list, adding an element to the end of the list, removing an element from the list, finding all students with a particular name, and sorting the list. These operations should be accessed through a menu driven interface:
Menu option | Effect |
(d)isplay | Display the contents of the list |
(a)add | Add a new element to the end of the list |
(r)emove | Remove an existing element from the end of the list |
(f)ind | Find all students with a particular name |
(s)ort | Sorting the list in ascending order according to student ID number |
(q)uit | Quit the program |
Your program will: initialize the list to the starting values specified below, allow the user to display the list onscreen, and to quit the program.
Initializing the list. When the program is first runs the list will contain 6 elements which are to be initialized to the values shown in the tables below. The ID number and name fields will be the same every time that the program is run but the faculty and year of study are randomly generated.
Constant fields: ID and name
Element no. ID Full name 1 000001 Smiley Smith-1 2 000002 Smiley Smith-2 3 000003 Smiley Smith-3 4 000004 Smiley Smith-4 5 000005 Smiley Smith-5 6 000006 Smiley Smith-6
Randomly initialized field: The probability for a particular student being registered in a particular faculty are shown in the table below.
Faculty Faculty code Proportion of class Science SC 50% Management MG 25% Social Sciences SS 25%
Randomly initialized field: The probability of a particular student being in the different years of study are shown in the table below.
Year of study Proportion of class 1 85% 2 10% 3 3% 4 2%
Displaying the list. Your program will display all non-empty list elements from beginning to end. Although the exact format of the output can vary, it must look neat and legible. One example format could be:
Displaying class list Student #1 Name: Smiley Smith-1 ID: 1 Faculty: SC Year: 1 Student #2 Name: Smiley Smith-2 ID: 2 Faculty: MG Year: 4 : : If the list contains no elements then the program should indicate to the user that no elements will be displayed because the list is empty.
When the user selects this function from the menu your program will prompt the user to enter in the information for the new student and that student will be added to the end of the class list. Your program must be able to handle a list of up to 20 students (inclusive). If the user tries to add additional students then your program should display an appropriate error message e.g., "Unable to add student because class is already full."
This function will remove the last element from the list. If the list currently empty then the program will display some sort of error message e.g., "Unable to remove student because class is currently empty."
When the user selects this function from the menu a prompt will appear asking him or her the name of the student to be found. The program will then step through the list and display all matches. For example suppose that the user wants to find all students in the class whose name is "Smiley Smith-1":
All instances of "Smiley Smith-1": Name: Smiley Smith-1 ID: 000001 Faculty: SC Year: 1
Although your lab TA will show you how to write a Bubble Sort in lab, you can employ any sorting algorithm in order to sort the list.
The student has invested considerable time and effort into the assignment, the program does not fulfill any of the above requirements but it does compile.
The student has invested considerable time and effort into the assignment, the program does not fulfill any of the above requirements and it does not compile.
2. Include a README file in your submission: For this assignment your README file must indicate what features have been completed. This will allow your marker to quickly determine what he or she must look for and speed up the marking process. Also indicate if you use any external libraries (other than the tio or the ones produced by Sun).
3. Assignments (source code and the README file) must be electronically submitted via submit. In addition a paper print out of the source code and the README file must be handed into the assignment drop box for the lab that you are registered in (located on the second floor of the Math Sciences building). Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented. Providing a paper printout makes it easier for your marker to read and flip through your source code.