Subject Computer Science C-Family Programming


This project gives you a chance to review and understand the important features that C++ and STL promise through programming practice. Please read the following instructions carefully.

Contents and Structure
The project mainly covers three features: STL, inheritance and polymorphism

Part 1
In this part, you design and implement all the classes in the UML diagram on the last page. Polymorphism is emphasized.

a) general specifications:

 Data members of Student class are protected
 All member functions are public; constructors may have several parameters
 In Student class, functions print() and tuition() are virtual and tuition() is pure (they must be overridden in DCL)
 Print functions must print all the data members in a nice format (e.g. add “endl”; “student name: ***”, etc)

b) call print() and tuition() for the following three students using both static and dynamic binding:

under_rate = 380.0; grad_rate = 500;
 “Mary”, “000111222”, “Junior”, 12 credits, her tuition, her gpa (4.0)
 “David”, “111222333”, graduate student, 9 credits, his tuition, his thesis (“How to learn data structures using C++/STL?”), his gpa (3.7)
 “Jason”, “222333444”, graduate assistant, 9 credit hours, his tuition, his thesis (“Design of efficient algorithms”), his gpa (3.9) his task (“Grading 330 projects and implementing a data mining algorithm”), his hourPay ($20), his superviser (“Dr. Fu”)
These are just facts data; your final output may look differently (but nicely).

Part 2
This part involves I/O streams, files, and STL.

Suppose that input undergraduate roster is a text file in which fields are separated by white-space “ ” and records by “\n”. For example, the first record (the fields are all in the following order: name, ssn, year, credits, gpa) could be
“Mary”, “000111222”, “Junior”, 12, 4.0

 Scan (read) the file and construct students one by one. Notice that, you should check the input data according to part a.
 Store the students in a list container (can insert one by one).
 After all students are scanned and pushed into the list, delete the last student and insert him/her to the front as the first student.
 Then print out on screen all the students using list iterator in the following format:

Header line:
Name SSN Year Credits Tuition GPA

In each line (including the header), each field’s width is 10 except “Name” whose width is 20. The last two fields are right-justified and have two fraction digits. Tuition must be padded with $ sign to the left. All other fields are left-justified.
 Then initialize a vector that contains the above list data and sort the students according to GPA. You must use generic sort algorithm (therefore need to overload “<” operator). After sorting, output the sorted students using the above format.

Submission Instruction

1) Code must be run on a UNIX machine.
2) Electrical copy uploading on Canvas (or by email) and hard copy are required for each submission.
3) You submit one source file named as “X_Undergrad.cpp” (X is your logon username e.g. l_fu ) and put all the drivers in the main function of class “Undergrad”. The output order appears as required above. If you have comments or “readme” things (and you should), put them in the beginning as a comment block.
4) File including the source file must be well-documented. Code is self-evident (e.g. clear names) and comments are concise, sufficient, and accurate.
X: your logon username.

For UML diagram see UML.jpg
Polymorphism C++ Abstract Class

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

class Student
Student(char name[21], char ssn[10], float gpa, int credits);
// Added for print purposes
char * get_name();
char * get_ssn();
int get_credits();
float get_gpa();
virtual char * get_year(){return 0;};

virtual void print();
virtual float tuition() = 0;
char name[21];
char ssn[10];
float gpa;
int credits;

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats