Write a C++ program that interacts with a text file that contains a list of student IDs and their corresponding grades for their test. The program will import the file contents into the program, separate the IDs and their grades, and then sort the students based on their grade in descending order.   The program will then display the top 10 scores, as well as the names of the students who earned those scores.     You will make a class called Student.  This class will have three attributes, one that stores their name, one that stores their grade, and one that stores a unique ID number.  Additionally, there will be setters and getters for each of the attributes, where the setter for “grade” should ensure that the grade is valid (i.e., between 0 and 100).  In addition to the setters and getters, you will overload the relational operators (i.e., ==, < > <= >= !=) in order to make student objects sortable.     The following rules apply for comparing students: Two or three student objects are equal if their IDs match. student_1 is “less than” student_2 based on the following priority: student_1’s grade is less than student_2’s If the grades are the same, then student_1’s name is less than student_2’s If both name and grade are the same, then student_1’s ID is less than student_2’s. Apply and interpret these rules for the rest of the relational operators. Once you have finished the class definition and test whether objects are correctly comparable, then you will load the student data from the file and use this data to generate a vector of student objects that contain the data. Afterwards, you will sort the vector.   To do this, you will need to implement a sorting algorithm (Note:  You are NOT permitted to use one of C++’s built in sorting algorithms).    You are allowed to choose either Quick Sort or Merge Sort for your algorithm.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Please write C++ code for the following. Please show all source code. Thank you.

Write a C++ program that interacts with a text file that contains a list of student IDs and their corresponding grades for their test. The program will import the file contents into the program, separate the IDs and their grades, and then sort the students based on their grade in descending order.   The program will then display the top 10 scores, as well as the names of the students who earned those scores.    

You will make a class called Student.  This class will have three attributes, one that stores their name, one that stores their grade, and one that stores a unique ID number.  Additionally, there will be setters and getters for each of the attributes, where the setter for “grade” should ensure that the grade is valid (i.e., between 0 and 100). 

In addition to the setters and getters, you will overload the relational operators (i.e., ==, < > <= >= !=) in order to make student objects sortable.    

The following rules apply for comparing students:

  • Two or three student objects are equal if their IDs match.
  • student_1 is “less than” student_2 based on the following priority:
    • student_1’s grade is less than student_2’s
    • If the grades are the same, then student_1’s name is less than student_2’s
    • If both name and grade are the same, then student_1’s ID is less than student_2’s.
  • Apply and interpret these rules for the rest of the relational operators.
  • Once you have finished the class definition and test whether objects are correctly comparable, then you will load the student data from the file and use this data to generate a vector of student objects that contain the data. Afterwards, you will sort the vector.   To do this, you will need to implement a sorting algorithm (Note:  You are NOT permitted to use one of C++’s built in sorting algorithms).    You are allowed to choose either Quick Sort or Merge Sort for your algorithm.   You may also use an existing solution, but it MUST be cited by placing a comment above the source code.

 The citation requirements are as followed:

  • /*
  • Website Name:
  • Date Accessed:
  • URL:
  • */
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education