n c++   i have this struct    struct Student {     string firstName, lastName;     int pointTotal; }; void printStudent(const Student & s) {     cout << s.pointTotal << "\t" << s.lastName << ", " << s.firstName << endl; } void printAll(Student students[], int numStudents) {     for (int i = 0; i < numStudents; i++)         printStudent(students[i]);     cout << endl; } int main() {     const int NUMSTUDENTS = 7;     Student students[NUMSTUDENTS] = { {"Brian", "Jones", 45},{"Edith", "Piaf", 45}, {"Jacques", "Brel", 64},{"Anna", "Brel", 64},       {"Carmen", "Jones", 45} , {"Carmen", "Brel", 64}, {"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} };     printAll(students, NUMSTUDENTS);     sortByPointTotal(students, NUMSTUDENTS);     printAll(students, NUMSTUDENTS);     return 0; }   i need to make a function that uses bubble sort(coded from scratch), but modify it so that the comparison for out-of-order elements takes into account all three fields: totalPoints, lastName and firstName, in decreasing order of importance.  In other words... sort by totalPoints as the primary criterion and put bigger point totals before smaller point totals. Then among students with the same totalPoints, sort by lastName, putting students with an alphabetically smaller last name before students with an alphabetically bigger last name. Finally among students with the same totalPoints and lastName, sort by firstName, again in ascending order.   the output should look like the image like

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

in c++

 

i have this struct 

 

struct Student {
    string firstName, lastName;
    int pointTotal;
};

void printStudent(const Student & s) {
    cout << s.pointTotal << "\t" << s.lastName << ", " << s.firstName << endl;
}
void printAll(Student students[], int numStudents) {
    for (int i = 0; i < numStudents; i++)
        printStudent(students[i]);
    cout << endl;
}

int main() {
    const int NUMSTUDENTS = 7;
    Student students[NUMSTUDENTS] = {
{"Brian", "Jones", 45},{"Edith", "Piaf", 45},
{"Jacques", "Brel", 64},{"Anna", "Brel", 64},
      {"Carmen", "Jones", 45} , {"Carmen", "Brel", 64},
{"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} };
    printAll(students, NUMSTUDENTS);
    sortByPointTotal(students, NUMSTUDENTS);
    printAll(students, NUMSTUDENTS);

    return 0;

}

 

i need to make a function that uses bubble sort(coded from scratch), but modify it so that the comparison for out-of-order elements takes into account all three fields: totalPoints, lastName and firstName, in decreasing order of importance.  In other words... sort by totalPoints as the primary criterion and put bigger point totals before smaller point totals. Then among students with the same totalPoints, sort by lastName, putting students with an alphabetically smaller last name before students with an alphabetically bigger last name. Finally among students with the same totalPoints and lastName, sort by firstName, again in ascending order.

 

the output should look like the image like 

Jones, Brian
Piaf, Edith
Brel, Jacques
Brel, Anna
Jones, Carmen
Brel, Carmen
Piaf, Antoine
Piaf, Pascal
45
45
64
64
45
64
45
64
Brel, Anna
Brel, Carmen
Brel, Jacques
Piaf, Pascal
Jones, Brian
Jones, Carmen
64
64
64
64
45
45
Piaf, Antoine
Piaf, Edith
45
45
Transcribed Image Text:Jones, Brian Piaf, Edith Brel, Jacques Brel, Anna Jones, Carmen Brel, Carmen Piaf, Antoine Piaf, Pascal 45 45 64 64 45 64 45 64 Brel, Anna Brel, Carmen Brel, Jacques Piaf, Pascal Jones, Brian Jones, Carmen 64 64 64 64 45 45 Piaf, Antoine Piaf, Edith 45 45
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
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
  • SEE MORE 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