Grade Calculating Program in C++

This Program calculate the grades in a exam in C++ Program . The Program asked user for his desire grade and then his marks in sessional exam. After this the program will calculate his marks according to the formula and prompt to the user rather you can gain this grade or not . Note down that you can change the grading policy according to the requirements .

Source Code

#include<iostream>
using namespace std;
int main()
{
float SessionalMarks = 0.0f;
int A=80, B=70, C=60, D=50,F=0;
int FinalTotalPercentage = 40;
int FinalTotalMarks = 100;
int SessionalPolicy = 60;
char DesireGrade;
cout<<" \n\n\n ************* MARKS REQUIRED For GRADE ****************\n\n\n ";
cout<<" Please enter your desire grade in Programming : ";
cin>>DesireGrade;
cout<<" Please enter your sessional marks in Programming : ";
cin>>SessionalMarks;
float MarksRequired = 0.0f, Percentage = 0.0f,DesiredMarks = 0.0f;
if(SessionalMarks>0 && SessionalMarks<=SessionalPolicy)
{
if(DesireGrade == 'a' || DesireGrade == 'A') //user can enter capital or small a
{
MarksRequired = A-SessionalMarks;
Percentage = (MarksRequired/FinalTotalPercentage);
DesiredMarks = Percentage*FinalTotalMarks;
if(DesiredMarks>FinalTotalMarks) //if marks are greater than 100
cout<<"Sorry you can't obtain \"" << DesireGrade << "\" Grade in Programming : " <<endl;
else
cout<<"You need \""<< DesiredMarks <<"\" Marks to obtain "<< DesireGrade <<" Grade" <<endl;
}//end of if(DesireGrade=='a' || DesireGrade=='A')
else if(DesireGrade=='b' || DesireGrade=='B')
{
MarksRequired=B-SessionalMarks;
Percentage=(MarksRequired/FinalTotalPercentage);
DesiredMarks=Percentage*FinalTotalMarks;
if(DesiredMarks>FinalTotalMarks) //if marks are greater than 100
cout<<"Sorry you can't obtain \""<<DesireGrade<<"\" Grade in Programming : "<<endl;
else
cout<<"You need \""<<DesiredMarks<<"\" Marks to obtain "<<DesireGrade<<" Grade"<<endl;
}//end of else if(DesireGrade=='b' || DesireGrade=='B')
else if(DesireGrade=='c' || DesireGrade=='C')
{
MarksRequired=C-SessionalMarks;
Percentage=(MarksRequired/FinalTotalPercentage);
DesiredMarks=Percentage*FinalTotalMarks;
if(DesiredMarks>FinalTotalMarks) //if marks are greater than 100
cout<<"Sorry you can't obtain \""<<DesireGrade<<"\" Grade in Programming : "<<endl;
else
cout<<"You need \""<<DesiredMarks<<"\" marks to obtain "<<DesireGrade<<" Grade"<<endl;
}//end of else if(DesireGrade=='c' || DesireGrade=='C')
else if(DesireGrade=='d' || DesireGrade=='D')
{
MarksRequired=D-SessionalMarks;
Percentage=(MarksRequired/FinalTotalPercentage);
DesiredMarks=Percentage*FinalTotalMarks;
if(DesiredMarks>FinalTotalMarks) //if marks are greater than 100
cout<<"Sorry you can't obtain \""<<DesireGrade<<"\"Grade in Programming : "<<endl;
else
cout<<"You need \""<<DesiredMarks<<"\" Marks to obtain "<<DesireGrade<<" Grade : "<<endl;
}// end of else if(DesireGrade=='d' || DesireGrade=='D')
else if (DesireGrade=='f' || DesireGrade=='F')
cout<<"You are going to fail.. don't do anything!!";
else
cout<<"Wrong grade entered";
} //end of if(SessionalMarks>0 && SessionalMarks<=SessionalPolicy)
}

Output of the Program

 calculating the grade in exam

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment