Friday 22 December 2017

C++ program For Calculating University CGPA

#include <iostream>
using namespace std;
class Profile
{
                public :
                                string name;
                                string rollno;
                                void getdata()
                                {
                                                system("color 0a");
                                                cout<<"Welcome to UOG CGPA calculator program designed by :\n";
                                                cout<<"\t\tMuqadas Saleem\n";
            cout<<"Enter your name\n";
                                                cin>> name;
                                                cout<<"Enter your roll no\n";
                                                cin>> rollno;
                                }
               
};
class GPA: public Profile
{
                public :
 void calculate()
{
               
                float gpnt1=0.00,gpnt2=0.00,gpnt3=0.00,gpnt4=0.00,gpnt5=0.00,gpnt6=0.00,gpnt7=0.00,gpnt8=0.00,gpnt9=0.00;
    int a;
    int grade;
    int ch=0,ch1=0,ch2=0,ch3=0,ch4=0,ch5=0,ch6=0,ch7=0,ch8=0,ch9=0;
    system("cls");
    system("color 0a");
    cout<<"How many subjects you have:\n";
    cin>>a;
    system("cls");
    system("color f0");
      
      cout<<"--------------------------------------------------------------------------------\n";
      cout<<"                              SCALE                                             \n";
      cout<<"--------------------------------------------------------------------------------\n";
      cout<<"                                                                                \n";
      cout<<"________________________________________________________________________________\n";
      cout<<"       marks in %age   |      Grade            |    GPA    |  Grade key         \n";
      cout<<"_______________________|_______________________|___________|____________________\n";
      cout<<"        84.5 and above |        A+             |    4.00   |     1 for A+       \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        79.5 to 84     |        A              |    3.70   |     2 for A        \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        74.5 to 79     |        B+             |    3.40   |     3 for B+       \n";        
      cout<<"                       |                       |           |                    \n";
      cout<<"        69.5 to 74     |        B              |    3.00   |     4 for B        \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        64.5 to 69     |        B-             |    2.50   |     5 for B-       \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        59.5 to 64     |        C+             |    2.00   |     6 for C+       \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        54.5 to 59     |        C              |    1.50   |     7 for C        \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        49.5 to 54     |        D              |    1.00   |     8 for D        \n";
      cout<<"                       |                       |           |                    \n";
      cout<<"        49 and below   |        F              |    0.00   |     9 for F        \n";
      cout<<"--------------------------------------------------------------------------------\n";
      cout<<"                                                                                \n";
      cout<<"--------------------------------------------------------------------------------\n";
       cout<<"\n\n\n    NOTE :(use special keys for grading as above in scale)\n\n\n";
       cout<<"please enter only 1 to 9 for grades as above in scale\n\n";
    for(int b=1;b<a+1;b++)
    {
     
     
      cout<<"Enter your Grade key in subject no:"<<b<<"\n";
    
      cin>>grade;
      if(grade==1)
      {
      cout<<"Enter credit hours:\n";
      cin>>ch;
       gpnt1=4.00*ch;
      }
      else    
      if(grade==2)
      {
      cout<<"Enter credit hours:\n";
      cin>>ch1;
       gpnt2=3.70*ch1;
      }
      else    
      if(grade==3)
       {
       cout<<"Enter credit hours:\n";
       cin>>ch2;
        gpnt3=3.40*ch2;
      }
      else    
      if(grade==4)
      {
     cout<<"Enter credit hours:\n";
      cin>>ch3;
      gpnt4=3.00*ch3;
      }
      else    
      if(grade==5)
      {
      cout<<"Enter credit hours:\n";
      cin>>ch4;
       gpnt5=2.50*ch4;
      }
      else    
      if(grade==6)
      {
       cout<<"Enter credit hours:\n";
      cin>>ch5;
       gpnt6=2.00*ch5;
      }
      else    
      if(grade==7)
      {
      cout<<"Enter credit hours:\n";
      cin>>ch6;
       gpnt7=1.50*ch6;
      }
      else    
      if(grade==8)
      {
      cout<<"Enter credit hours:\n";
      cin>>ch7;
      gpnt8=1.00*ch7;
      }
      else    
      if(grade==9)
      {
         cout<<"Enter credit hours:\n";
      cin>>ch8;
       gpnt9=0.00*ch8;
      }
      else
      cout<<"Wrong value";
                      }
                       float tgpnt=gpnt1+gpnt2+gpnt3+gpnt4+gpnt5+gpnt6+gpnt7+gpnt8+gpnt9;
                       int tch=+ch+ch1+ch2+ch3+ch4+ch5+ch6+ch7+ch8+ch9;
                      float cgpa= tgpnt/tch;
                      system("cls");
                      cout<< "dear "<<name;
                       if (cgpa >= 3)
                                        cout << "\nCongratulations, your GPA is "  << cgpa << endl;
                                        else
                                        cout << "\nSorry dude, your GPA is "  << cgpa << endl;
                           cout<<"THE END\n";
    system("pause");
               
}
               
                };
               

int main()
{
               
                GPA obj;
                obj.getdata();
                obj.calculate();
                return 0;
}

1 comments:

  1. Sands Casino, Atlantic City | Sign up now & play with $10 free bonus
    Enjoy 인카지노 gaming at Sands Casino's 400+ 1xbet slot machines, table games, poker, blackjack, live dealer casino and more! | SIGN UP NOW. septcasino

    ReplyDelete

Tech UOG