Introduction to Computer Science II by James Tam Return to the course web page

CPSC 233: Assignment 3 (Worth 5%)

 

Due Friday February 13

Tracking a class list

You are to implement a program that allows the user to manage a list of up to 20 students.  The student information tracked by the program includes:

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

 

Grading: Working submissions

Basic submission (C+)

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.

Extra features

In order to receive a grade higher than a C+ , you must first fulfill all the requirements of a C+ assignment.  The extra features can be completed in whatever combination that you want.

Add an element to the end of the list (worth an increase of 1 letter step)

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."

Remove an element from the end of the list (worth an increase of 1 letter step)

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."

Search for an element (worth an increase of 1 letter step)

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

Sort the list into ascending order according to ID number (worth an increase of 2 letter steps).

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 extra features can be implemented in any combination by the student on top of the basic (C+ level) assignment e.g., If you implemented the remove element and sort features but not the add or search features then you would receive a grade of B+ (C+ plus 1 step for the remove function and 2 steps for the sort function).

 

Grading: Non-working submissions

D submissions:

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.

D- submissions:

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.

 

Submission requirements for this assignment

In addition to having fulfill the generic assignment requirements, the requirements specific to this assignment include:

1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a letter step (e.g., "A" to "A-" for poor programming style such as employing poor naming conventions for identifiers).

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.

 

New Concepts to be applied for the assignment

  1. Dynamic memory allocation in Java (arrays of references)
  2. Basic list operations

 

External libraries that can be used

  1. Libraries that allow for text-based (console) input and output.
  2. Libraries that will randomly generate numbers (e.g., class Random or class Math).
  3. You cannot use Java classes that automatically handle the list functions for you (e.g., class Vector and the Collections).