Search Your Query

Custom Search

Tuesday 24 May 2011

GPA Ranking/ Position Ranking Program


#include <iostream.h>
#include <iomanip.h>

void main()
{
    int num[46]={1,2,3,5,6,7,8,12,14,15,17,18,19,21,24,25,27,29,30,32,33,34,35,38,39,40,41,42,43,46,47,49,50,52,53,55,56,57,59,60,61,62,63,64,65,66};
    double gpa[46]={4.0,2.61,3.76,3.48,3.58,2.68,3.89,2.34,3.48,3.19,2.88,3.28,2.61,3.36,1.93,2.87,3.66,3.43,2.98,1.64,2.85,2.94,3.24,2.13,2.48,2.02,3.51,3.57,3.38,3.24,1.49,2.02,2.93,3.19,2.06,1.94,3.32,3.08,3.19,2.98,1.85,3.06,2.45,3.06,2.72,1.19};
 
    int max;
    double temp,t;
    for ( int i=0 ; i < 46 ; i++ )
    {
        max=0;  
        for ( int j=0 ; j < 46-i ; j++ )
        {
            if ( gpa[j] > gpa[max] )
            {
                max=j;
            }
            temp = gpa[max];        t=num[max];
            gpa[max] = gpa[45-i];    num[max]=num[45-i];
            gpa[45-i] = temp;        num[45-i]=int(t);
        }
     
    }

    cout << setw(10) << "Rank" << setw(18) << "Registeration #" << setw(9) << "GPA" << setw(20) << "Remarks" << endl << endl;
 
    for ( i=45 ; i>=0 ; i-- )
    {
        cout << setw(10) << 46-i << setw(14) << "(08-TE-" << num[i];
        if ( num[i] < 10 )
            cout << " )" << setw(10) << gpa[i];// << endl << endl;
        else
            cout << ")" << setw(10) << gpa[i];//endl << endl;
 
        if ( gpa[i] == 4.00 )
            cout << setw(20) << "Spectacular!" << endl << endl;
        else if ( gpa[i] >= 3.50 )
            cout << setw(20) << "Excelent!" << endl << endl;
        else if ( gpa[i] >= 3.00 )
            cout << setw(20) << "Very Good!" << endl << endl;
        else if ( gpa[i] >= 2.50 )
            cout << setw(20) << "Good!" << endl << endl;
        else if ( gpa[i] >= 2.00 )
            cout << setw(25) << "Nice. Try to Improve!" << endl << endl;
        else
            cout << setw(30) << "Dont Worry, Try to Improve!" << endl << endl;
    }

}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...