C/C++ 编程代写
当前位置:以往案例 > >案例CS-C语言案例DATA STRUCTURES AND ALGORITHMIC PROBLEM
2017-12-14



PLEASE READ THE QUESTION CAREFULLY BEFORE YOU START.

1. OBJECTIVE

(a) To review and strengthen concepts about linked lists through an application development.

(b) To review techniques of dynamic data structure creation and manipulation.



2. EQUIPMENT
Hardware: The PCs in the lab for conducting your practical.

Software: The Microsoft Visual Studio 2015. Your programming will only be tested by the markers using Visual Studio 2015.



3. INDIVIDUAL OR GROUP PROJECT:

Form a group of 1 to 2 persons (MUST BE FROM THE SAME PRACTICAL SESSION). Select one person to be the leader. Only one person need to upload the project to WBLE for submission. However, please remember to  include your group member name in the readme.txt file.



4. DESCRIPTION OF PROJECT:

In this project, you need to write the functions given in the main() that will store and manage student information in FICT using linked lists. Three classes have been created, which are Student class,  class and Subject class. Student class is used to store student information and the  class is used to store information for past  for a student in a trimester. The Subject class is used to store information for a subject taken by student. Refer to the Figure1.doc given for the representation of the types of linked list that you are going to create. Below are the details for each of the classes:



PLEASE DO NOT CHANGE (ADD/REMOVE) ANY ATTRIBUTES OR FUNCTIONS IN LIST, NODE, STUDENT,  AND SUBJECT STRUCTS GIVEN TO YOU. MARKS WILL BE DEDUCTED IF YOU DO SO.

Student Struct:


Refer to the file Student.h for all the members in the struct. Refer to the table below for the format of the data stores for each attributes in Student struct.


Attributes

Format

name

A c-string with 30 characters

id

A c-string t represent id. Student id consists of 7 digits with the first 2 digit represent years enroll. E,g.: 1300345

course

Use 2 characters to represent: CS – Computer Science

IA – Information Systems Engineering IB – Business Information Systems CN – Communication and Networking CT – Computer Engineering

phone_no

A 7 digits number in the following

format: 123-4567

current_cpga

The latest cgpa for a student with 5 decimal places. E.g.: 3.51762

totalCreditsEarned

Total credits earned so far.



An array to store past  for a student according to trimester. This array can

store up to 10 trimester result.

_cnt

A counter to keep track of the number of past  result store in  array.


The following member functions are given in the struct:


1. Constructor Student() to initialized name, id, course and phone_no to empty string (use strcpy) and current_cgpa, _cnt and totalCreditsEarned to 0.


2. Function bool compareName1 (Student) to compare student name using >= operator. You can use this function to compare which student’s name come first according to alphabetical order. It is used in the second insert function.


3. Function bool compareID (Student) to compare student id using == operator. You can use this function to search for student in a linked list based on id.


4. Function void print(ostream &) to print Student struct variable. The argument pass to the function is used to determine which stream to print the output.


5. Function bool calculateCurrentCGPA() to calculate the current cgpa for a student.



Struct:



Refer to the file .h for all the members in the struct. Refer to the table below for the format of the data stores for each attributes in  struct.


Attributes

Format

trimester

Store the trimester of the  using integer to represent the 3 trimester in a year as follow:

1 – January Trimester 5 – May Trimester

10 – October Trimester

year

A four digit integer to represent the year of the .

gpa

GPA obtained for a trimester. Use 5 decimal points to represent the value.

numOfSubjects

The number of subjects taken in that

trimester.

sub[]

The subject information taken in that trimester. Each element is an object of class Subject. Maximum only 6 subjects can be taken and minimum is 1 subject.


The following member functions are given in the  struct:


1. Constructor () to initialized trimester, year, gpa and numOfSubjects to 0.


2. Function bool calculateGPA() to calculate the gpa for an  in a trimester based on the grade and number of subjects take. Refer to file Figure2.doc for the grade point based on the marks obtained.


3. Function void print(ostream &) to print the  struct variable. The argument pass to the function is used to determine which stream to print the output.


Subject Struct:



Refer to the file Subject.h for all the members in the Subject struct. Refer to the table below for the format of the data stores for each attributes in Subject struct.


Attributes

Format

subject_code

A string with 10 characters to represent a code for a subject. First four characters represent must be alphabet and last four

are digits.

subject_name

A string represents the subject names.

credit_hours

Number of credit hours for a subject.

marks

Marks obtained for a subject. Range is from 1 to 100.


The following member functions are given in the Subject struct:


1. Constructor Subject() to initialized subject_code and subject_name to empty string (use strcpy) and credit_hours, and marks to 0.


2. Function const char *getGrade() to return the grade (A+, A, B+, …) for a subject based on the marks. Refer to file Figure2.doc for the grade return based on the marks obtained.


3. Function double getGradePoint() to return the grade point for a subject based on the marks obtained. Refer to file Figure2.doc for the grade point return.


4. Function void print(ostream &) to print Subject struct variable. The argument pass to the function is used to determine which stream to print the output.


Main() Tasks:



You need to write the following functions in main().


1. Write a function bool ReadFile(char *filename, List *list) to read from a file  that store student information in a linked list. Ensure there is no duplicate record  of student stored in the list. The function will return true if successfully read and false otherwise. A sample of the textfile is in “student.txt”.


2. Write a function bool DeleteRecord(List *list, char *id) to delete a student from the linked list based on student id. The function will return true if successfully delete and false if student cannot be found in the list.


3. Write a function bool Display(List list, int source) that will display information to the screen. Function return false if list is empty and true otherwise. The source variable will indicate whether to display to screen (source = 1) or file (source = 2). If write to file, use the filename “student_result.txt” to write. A sample of each of the output option is given in text file in folder sample output. If the student’s _cnt = 0, then print “THIS STUDENT HAVEN’T TAKEN ANY  YET”. You can design your own output format but the necessary details must be there.


4. Write a function bool InsertResult(char *filename, List *list) to insert student  result to the linked list. Open the file with filename and read every record and find the student to insert the  based on their id. A sample of the text file is in “.txt”. Read every record in the file and put the  info in an  struct variable. Then find the correct student based on id to insert the  struct variable. You need to calculate the current cgpa every time you insert a new  to a student.


5. Write a function bool printStatistic(List list) that will find and print the statistics for the student list as below. Average subject taken per semester is how many subjects are taken averagely for one student in one semester. Similar for average credit hours earned per semester. The function will return false for empty list and true otherwise.


Sample Output:

Total Students: 20 CS Students – 6 IA Students – 5 IB Students – 3 CN Students – 3 CT Students – 3


Average CGPA: 3.15670

Average Subjects Taken Per Semester: 3.23 Average Credits Earned Per Semester: 26.57


6. Write a function bool findEligibleFYPStudent(List list1, List *FYPlist) that  will identify student that can register for FYP (Final Year Project). A student is



eligible to register for FYP if he/she has earned at least 30 credits hours and the student has taken and passed (must obtain at least grade C) UCCD2502 Introduction to Inventive Problem Solving and UCCD2513 Mini Project. Call Display(FYPlist, 1) in main() after function call to display FYPlist. If FYPlist is empty print message “There is no student that is eligible to take FYP”. Assume that list FYPlist is empty when pass to function and list will not be changed after function call. The function will return false for empty list1 and true otherwise.


7. Write a function bool identifyGoodPoorStudent(List list1, List *goodList, List

*poorList) that will identify student with good result and poor result in list1. A student is considered to have good result if he/she can get gpa >= 3.50000 for at least 3 trimesters in all the s and CGPA >= 3.50000 and no fail subject. A poor student is a student that get gpa <= 2.0000 for at least 3 trimester and CGPA

<= 2.0000. Copy all the good result students to list goodList and all the poor students to list poorList. Call function Display(goodList, 1) and Display(poorList,

1) in main() to print goodList and poorList in the screen after calling the function. Assume goodList and poorList are empty when pass to function and list1 content will not be changed after function call. If either the goodList or the poorList is empty after function all, then print message “There is no student in good list” or “There is no student in poor list”. The function will return false for empty list1 and true otherwise. (Note: If a student has taken < 3 s then no need to check if the student belongs to good or poor list.)


8. Write a int menu() function that contain menu with choice from 1 to 8 above to  let user choose that task. Function will return the choice chosen. Make sure user can conti

在线提交订单