2. Computerprogramming1st
assignment
2
Creating a GPA Calculatorthat will also find students grades.
#include <iostream>
usingnamespace std;//usingstandard
int main()
{int sb1,sb2,sb3,sb4,sb5,chr1,chr2,chr3,chr4,chr5;//declaringintegers
cout<<"welcome to u n";
cout<<"Enter the marks of subject 1 n";
cin>>sb1;//it will ask for the marks of subject 1
cout<<"Enter the credit hours of subject 1 n";
cin>>chr1;//it will ask for the credit hours of subject 1
cout<<"Enter the marks of subject 2 n";
cin>>sb2;//it will ask for the marks of subject 1
cout<<"Enter the credit hours of subject 2 n";
cin>>chr2;//it will ask for the credit hours of subject 1
cout<<"Enter the marks of subject 3 n";
cin>>sb3;//it will ask for the marks of subject 1
cout<<"Enter the credit hours of subject 3 n";
cin>>chr3;//it will ask for the credit hours of subject 1
cout<<"Enter the marks of subject 4 n";
cin>>sb4;//it will ask for the marks of subject 1
cout<<"Enter the credit hours of subject 4 n";
cin>>chr4;//it will ask for the credit hours of subject 1
3. Computerprogramming1st
assignment
3
cout<<"Enter the marks of subject 5 n";
cin>>sb5;//it will ask for the marks of subject 1
cout<<"Enter the credit hours of subject 5 n";
cin>>chr5;//it will ask for the credit hours of subject 1
double tcrh;//declaringtotal credit hours
tcrh=chr1+chr2+chr3+chr4+chr5;//total credit hours formulas
double GPA;//declaringGPA
GPA=(sb1*chr1+sb2*chr2+sb3*chr3+sb4*chr4+sb5*chr5)/tcrh;//GPA
formula
cout<<"THIS IS YOUR GPA n";
cout<<GPA;//Gives urGPA
char Grade;//declaringcharacter
if(GPA>0&&GPA<=20)//applyngdifferent conditionsforgrades
{Grade='F'; }
else if(GPA>20&&GPA<=40)
{Grade='E';}
else if(GPA>40&&GPA<=60)
{Grade='D';}
else if(GPA>60&&GPA<=70)
{Grade='C';}
else if(GPA>70&&GPA<=80)
{Grade='B';}
else if(GPA>80&&GPA<=100)
5. Computerprogramming1st
assignment
5
3; when GPA is Greater than 100 grade will be “I” (INVALID).
4; when GPA is between 0 and 20 grade will be “F”.
**************************************************************