RCMS.cpp
/**************************SORTING BY GRADES**************************/
/*
To begin with, a subject is selected to display the grades in. Once a subject is selected,
the records are then sorted.

The records are sorted based on the top five grades, and then they are displayed along with the
name of the student associated with that grade. 

Finally, the user returns back to their access level function, Student(), Teacher(), or Public(), and 
they are able to make another selection
*/
SORTING BY GRADES
To begin with, a subject is selected to display the grades in. Once a subject is selected,
the records are then sorted.

The records are sorted based on the top five grades, and then they are displayed along with the
name of the student associated with that grade.

Finally, the user returns back to their access level function, Student(), Teacher(), or Public(), and
they are able to make another selection
SORTING BY GRADES To begin with a subject is selected to display the grades in . Once a subject is selected the records are then sorted . The records are sorted based on the top five grades and then they are displayed along with the name of the student associated with that grade . Finally the user returns back to their access level function Student () Teacher () or Public () and they are able to make another selection
void sortgrades() {
    STUDENT s, t[100], temp;
    ifstream f("Record.dat");
    int x, y, n = 0;
    char ch[25];
    if (!f) {
        cout << "\n\n\n\n\n\n\n\n\n\n\n\t\t\t\tFILE NOT FOUND!";
        cout << "\n\n\n\n\n\n\n\n";
    } else {
        {
            while (f.read((char *) &s, sizeof(s))) {
                t[n++] = s;
            }
        }
        f.close();
        cout << "\n\n\n\n\n\n";
        cout << "\t\t\t  ----------------------" << "\n";
        cout << "\t\t\t     SELECT A SUBJECT" << "\n";
        cout << "\t\t\t  ----------------------" << "\n";
        cout << "\t\t\t       1. PHYSICS" << "\n";
        cout << "\t\t\t       2. CHEMISTRY" << "\n";
        cout << "\t\t\t       3. MATHS" << "\n";
        cout << "\t\t\t       4. BIOLOGY OR COMPUTER" << "\n";
        cout << "\t\t\t       5. ENGLISH" << "\n\n";
        cout << "\t\t\t     ENTER YOUR OPTION: ";
        cin >> y;
        system("cls");
        cout << endl;
        if (y > 5) {
            cout << "\n\n\n\n\n\n\n\n\n\n\n\t\t\t\tWRONG OPTION!";
            cout << "\n\n\n\n\n\n\n\n";
        } else
            x = y - 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n - 1; j++) {
                if (t[j].grades[x] < t[j + 1].grades[x]) {
                    temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;
                }
            }
        }
        cout << "\n\n\n\n\n\n";
        cout << "\t\t\t" << "-------------------------------" << "\n";
        cout << "\t\t\t" << "   SL. NO:" << "\t" << "GRADES" << "\t" << "NAME" << "\n";
        cout << "\t\t\t" << "-------------------------------" << "\n\n";
        for (int i = 0; i < 5; ++i) {
            cout << "\t\t\t   ";
            cout << i + 1 << ". " << "\t\t";
            cout << t[i].grades[x] << "\t" << t[i].name;
            cout << endl;
        }
        cout << "\n\n\n";
    }
}
void sortgrades ( ) { STUDENT s , t [ 100 ] , temp ; ifstream f ( " " ) ; int x , y , n = 0 ; char ch [ 25 ] ; if ( ! f ) { cout << " \n \n \n \n \n \n \n \n \n \n \n \t \t \t \t " ; cout << " \n \n \n \n \n \n \n \n " ; } else { { while ( f . read ( ( char * ) & s , sizeof ( s ) ) ) { t [ n ++ ] = s ; } } f . close ( ) ; cout << " \n \n \n \n \n \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n " ; cout << " \t \t \t " << " \n \n " ; cout << " \t \t \t " ; cin >> y ; system ( " " ) ; cout << endl ; if ( y > 5 ) { cout << " \n \n \n \n \n \n \n \n \n \n \n \t \t \t \t " ; cout << " \n \n \n \n \n \n \n \n " ; } else x = y - 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n - 1 ; j ++ ) { if ( t [ j ] . grades [ x ] < t [ j + 1 ] . grades [ x ] ) { temp = t [ j ] ; t [ j ] = t [ j + 1 ] ; t [ j + 1 ] = temp ; } } } cout << " \n \n \n \n \n \n " ; cout << " \t \t \t " << " " << " \n " ; cout << " \t \t \t " << " " << " \t " << " " << " \t " << " " << " \n " ; cout << " \t \t \t " << " " << " \n \n " ; for ( int i = 0 ; i < 5 ; ++ i ) { cout << " \t \t \t " ; cout << i + 1 << " " << " \t \t " ; cout << t [ i ] . grades [ x ] << " \t " << t [ i ] . name ; cout << endl ; } cout << " \n \n \n " ; } }
SORTING BY GRADES
To begin with, a subject is selected to display the grades in.
SORTING BY GRADES To begin with a subject is selected to display the grades in .
/*******************DISPLAYING THE SORTED RECORDS*******************/