Starting from:

$30

CS201-Homework 5 Student Grade Ranking Solved

Your program should read two input files; first one includes the names (i.e. first and last name) of the students with their ID numbers and the other one contains the grades of the corresponding students with their ID information (i.e. only the ID number is unique not the first or last names of the students).

In the student information file, there are white spaces in the student names. There is a single space between the first name, middle name and last name of the student to separate these. If a student does not have a middle name, then there will be only one single space between the name and the last name of the student (i.e. a student should have a first name as well as a last name but may not have a middle name). However, we do not use non-English letters, like ş, ö, ü, ğ, ı, ç, etc. in the student names. In this homework, you may assume that student names are given in this way (i.e. with blank information as previously explained and non-English letters are not used).

An example students information file is shown below:

 

In the grades file, there are grade results of different evaluation parts of a specific course (e.g. homework, midterm and final). In order to differentiate these, each evaluation scheme results begins with a constant line of one of these below:

***HOMEWORK***

***MIDTERM***

***FINAL***

After this line, there comes the id number of a student and the grade of the corresponding student for a particular assessment of the course line by line. There is only one student (i.e. id number of that student) on each line and his/her grade information for that particular assessment of the course. At the end of the id-grade information of the students for a specific assessment, there is an empty line.

Part of an example grade results file is shown below:

 

The number of students in the grades list may vary in each particular assessment of the course. Moreover, there may be several assignments (i.e. homework) or midterms of a specific course. Therefore, you cannot make any assumption about the number of specific evaluation schemes as well as the number of students in each evaluation criteria. Furthermore, you cannot make any assumption about the order of these assessments.

Obviously, a particular student is listed at most one time in a particular assessment, but a student may be absent in some of these assessments (i.e. student may not take the midterm1 assuming that no make-up or s/he may not submit one of the assignments). A student may be completely absent in the grades file, in this case he/she should not appear in the grades points table at all.

For the sample input files which contains the students and grades information, you may check out the students.txt and grades.txt files provided in this homework google drive folder respectively. However, please remark that the students and the grades file which will be used for grading your assignments may be different than this sample. THEREFORE, DO NOT MAKE ANY ASSUMPTIONS ABOUT THE CONTENT OF THESE FILES; JUST READ THE STUDENTS AND GRADES FILES AND PROCESS THEM.

The structure of the input file, the associated rules, assumptions and the things that you cannot assume, which are all explained above, are fixed such that you cannot change them or make any other assumptions. No format check for the contents of the input file is needed. You may assume that all data are in correct format.

The names of both of the input files are keyboard inputs. If the user enters a wrong file name that does not exist, then your program should display an appropriate error message (check samples for error message) and terminate the program immediately. It is not needed to (and please do not) ask for a new input file name.

Processing

You can use a struct data structure to encapsulate data of one student, such as student name, points, etc. It is up to you to decide which fields are to be included in this struct.

You can use a vector to store several students’ data. Of course, the element type of this vector will be the previously defined student struct. Here please remark that you CANNOT make any assumption about the number of students in the course. The sample grades data file that we provided in the google drive folder is partially taken from the results of a course. You can observe from this sample that there are different numbers of students in each assessment list. Therefore, your program should work for any number of students. Moreover, your program should work for any student names which are consistent with the naming rules discussed in the Input File Section. In the sample, we used real student names from a previous class, but we can use other names for grading purposes.

The points table is a sorted list of students rankings. The order is determined by the total points that each student gained through all course assessments in a specific course. If there is a tie in points meaning there are two students with the same points, some other criteria will be used to determine the order. These details will be explained below.

Flow of the program may be as follows:

− Your program should first ask for file name information from the user for the input files. Then, the user enters these file names from the keyboard. After that, your program opens the input files and tests for failure. If it fails to open any of these files, then the program will terminate with an appropriate message (see sample runs for the message).

− If it opens all of the files successfully, then your program processes the input files. The processing method will be line by line since there is data for a specific student on each line for the input files of student information and grade results.

●     Regarding processing the input files, first, you need to calculate the total points that a student achieved at the end of the course by using ID information since there is no name information in the grade results file (i.e. also name information is not unique to search for a

student).

●     As mentioned in the Input File Section, there are grades for different assessments of a course in the input file of grade results. A particular assessment starts with ***Homework***, ***Midterm***, or ***Final*** tag. After one of these tags, we have the student ID number and his/her grade for the corresponding assessment (one student data per line). You need to differentiate these tags as you read them since each of them has a distinct weight and will contribute to the total points of a student at various levels. The total points of the student will be the weighted sum of the grades that s/he achieved for these specific evaluations (i.e. tags).

●     The processing for each student of the particular assessment section in the grade results file is as follows (note that this is just a suggested algorithm, and there could be other ways to solve this, so please feel free to create your own algorithm as well as using this one):

-          If this student is not in the vector (i.e. if this is his/her first appearance in the grade results file), then create a new student struct for this student and add to the vector. As you process the grade results file, you should retrieve the names of the corresponding student on that line from the students file by using the ID number (i.e. ID number exists in both of the input files).

-          If this student is already in your vector, update this existing student struct. That is, if this student has occurred before in the grade results file, then there should be a struct in the vector for him/her. If this is the case, you should only update the necessary information about the corresponding student without adding a struct for him/her to the vector again.

-          Updating the data of a specific student: Update the total point of a student by adding the weighted sum of the points gained from the particular assessment to his/her previous points. The weights for each evaluation scheme of a course are given below. The number of assignments (i.e. homework) and midterms will be more than one since the sum of the weight percentages should be equal to 100% (i.e. overall course grade will be computed from all of these particular assessments). You may assume the total percentage of these in the file will sum up to 100%, however do not make any assumptions of the number of each assessment. For example; there could be 3 homework assignments, 2 midterms and 1 final as given in the grades.txt file OR 1 homework, 3 midterms and 1 final OR 5 midterms and 0 homework and final as given in the grades2.txt file in the homework drive folder.

Particular Assessment
Weight

Percentage
Homework
10%
Midterm
20%
Final
30%
− After your program finishes reading and processing all of the information in the input file of grade results and storing the necessary data in the vector, it should sort the vector in descending manner.

●     You may modify and use one of sorting algorithms provided by the book and/or discussed in the lecture. If you want to develop your own sorting algorithm, of course you may, but this will be more difficult.

●     You should sort the vector by points; students with higher points must be at higher positions in the table. If multiple students have the same point, then you should use the last name of the student; in this case the student with alphabetically smaller last name (in string comparison terms) must be at a higher position in the table. If multiple students have both the same point and last name, then they should be in any order in the table. You do not need to worry about it.

− Finally you display the message “Enter the rank you want to query (enter 0 to exit):” that asks the user to enter the rank number to query for. You will display this query message until the user enters 0 to exit the program.

Output

After your program has the sorted point table and the user enters a rank integer, the student information with the given rank is displayed on the screen. Four pieces of information must be displayed for the student queried; these are Rank of the student in the points table, ID number of the student, Name of the student (i.e. first name, middle name if exists and last name), Points that the student gained. These four pieces of information must be displayed in this order and there must be commas in between.

For the name of the student in the output, please use the following formats for the possible two cases (NO ADDITIONAL SPACES!):

i.                     FirstName-SingleSpace-MiddleName-SingleSpace-LastName (middle name exists) Example: Ali(space)Can(space)Akdeniz

ii.                   FirstName-SingleSpace-LastName (there is no middle name)

                                  Example: Gizem(space)(space)Gezici (wrong),                                      it     should    be

Gizem(space)Gezici (right)

In the google drive folder of this homework, we provide sample input files (students.txt, grades.txt with an example ranking table file also (results.txt). You may examine and of course use them to understand the homework and output format in detail.

Please see the sample runs for examples using these given input files.

Sample Runs

Below, we provide a sample run of the program that you will develop. The italic and bold phrases are inputs taken from the user. You should follow the input order in these examples and the prompts your program will display must be exactly the same as in the following examples.

Sample Run 1

Please enter a filename for Students Grades Results: grades Can not find the requested file. Terminating application ...

Sample Run 2

Please enter a filename for Students Grades Results: grades.txt Please enter a filename for Students Names : nothere.txt Can not find the requested file. Terminating application ...

Sample Run 3

Please enter a filename for Students Grades Results: grades.txt

Please enter a filename for Students Names : students.txt

Enter the rank you want to query (enter 0 to exit): 1
1, 00012287, Onur Akdeniz, 81.2

Enter the rank you want to query (enter 0 to exit): 4

4, 00011464, Alper Aydin, 74.7
Enter the rank you want to query (enter 0 to exit): 4

4, 00011464, Alper Aydin, 74.7

Enter the rank you want to query (enter 0 to exit): 19 Rank needs to be greater than 0 and smaller than 16!

Enter the rank you want to query (enter 0 to exit): 11

11, 00010926, Ekrem Sinan Aygun, 60.5

Enter the rank you want to query (enter 0 to exit): 7

7, 00011530, Burcu Aciksoz, 66.2

Enter the rank you want to query (enter 0 to exit): 8

8, 00010206, Gizem Gezici, 66.2

Enter the rank you want to query (enter 0 to exit): 14
14, 00011412, Yonca Betul Karadeniz, 57.5
Enter the rank you want to query (enter 0 to exit): 2

2, 00009029, Ali Can Akdeniz, 74.9

Enter the rank you want to query (enter 0 to exit): 15

15, 00008963, Selcuk Akaydin, 50.8

Enter the rank you want to query (enter 0 to exit): -5 Rank needs to be greater than 0 and smaller than 16! Enter the rank you want to query (enter 0 to exit): 314323 Rank needs to be greater than 0 and smaller than 16!

Enter the rank you want to query (enter 0 to exit): 5

5, 00009713, Ozge Karadeniz, 68.9

Enter the rank you want to query (enter 0 to exit): 0 Exiting...

Sample Run 4

Please enter a filename for Students Grades Results: grades2.txt

Please enter a filename for Students Names : students.txt Enter the rank you want to query (enter 0 to exit): 15 Rank needs to be greater than 0 and smaller than 14!

Enter the rank you want to query (enter 0 to exit): 13

13, 00011366, Yigit Akar, 54.6

Enter the rank you want to query (enter 0 to exit): 1

1, 00012287, Onur Akdeniz, 83

Enter the rank you want to query (enter 0 to exit): 5

5, 00009713, Ozge Karadeniz, 72.4

Enter the rank you want to query (enter 0 to exit): 0 Exiting...

Use of Functions and Other Rules

Unlike the second homework, we will not specify any functions here. But you are expected to use functions to avoid code duplication and improve the modularity of your program. If your main function or any user-defined function is too long and if you do everything in main or in another user-defined function, your grade may be lowered.

AND PLEASE DO NOT WRITE EVERYTHING IN MAIN AND THEN TRY TO SPLIT THE TASK INTO SOME FUNCTIONS JUST TO HAVE SOME FUNCTIONS OTHER THAN MAIN. THIS IS TOTALLY AGAINST THE IDEA OF FUNCTIONAL DESIGN AND NOTHING BUT A DIRTY TRICK TO GET SOME POINTS. INSTEAD PLEASE

DESIGN YOUR PROGRAM BY CONSIDERING NECESSARY FUNCTIONS AT THE BEGINNING.

Try to use parametric functions and avoid inputs in functions. Do NOT use any global variables (variables defined outside the functions) to avoid parameter use.

As in the previous homework, no abrupt program termination is allowed in the middle of the program! The program flow should continue until the end of the main function.

No abrupt program termination please!

You may want to stop the execution of the program at a specific place in the program. Although there are ways of doing this in C++, it is not a good programming practice to abruptly stop the execution in the middle of the program. Therefore, your program flow should continue until the end of the main function and finish there.

More products