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

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter6: Managing Multiple Worksheets And Workbooks
Section: Chapter Questions
Problem 2.6CP
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.
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781285867168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning