GPA calculator and grading program in c++

7
Computer programming 1 st assignment Name: Taimur Muhammad Class No: 12 Assignment No: 02 Subject: Computer programming Topic: C++ Programming Submitted to: Engineer Durr-e-Nayab 1

Transcript of GPA calculator and grading program in c++

Page 1: GPA calculator and grading program in c++

Computer programming 1st assignment

Name: Taimur Muhammad

Class No: 12

Assignment No: 02

Subject: Computer programming

Topic: C++ Programming

Submitted to: Engineer Durr-e-Nayab

Dated: 24-10-2016 Creating a GPA Calculator that will also find students grades.

1

Page 2: GPA calculator and grading program in c++

Computer programming 1st assignment

#include <iostream>

using namespace std;//using standard

int main()

{int sb1,sb2,sb3,sb4,sb5,chr1,chr2,chr3,chr4,chr5;//declaring integers

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

cout<<"Enter the marks of subject 5 \n";

2

Page 3: GPA calculator and grading program in c++

Computer programming 1st assignment

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;//declaring total credit hours

tcrh=chr1+chr2+chr3+chr4+chr5;//total credit hours formulas

double GPA;//declaring GPA

GPA=(sb1*chr1+sb2*chr2+sb3*chr3+sb4*chr4+sb5*chr5)/tcrh;//GPA formula

cout<<"THIS IS YOUR GPA \n";

cout<<GPA;//Gives ur GPA

char Grade;//declaring character

if(GPA>0&&GPA<=20)//applyng different conditions for grades

{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)

{Grade='A';}

3

Page 4: GPA calculator and grading program in c++

Computer programming 1st assignment

else

Grade='I';

cout<<"\n From ur data ,your GRADE is \n";

cout<<Grade;//it will give you ur grade

return 0;

}

OUTPUT:-1; When GPA is b/w 40 and 60 GRADE will be “D”.

2; when GPA is b/w 80 and 100 gives “A” grade.

3; when GPA is Greater than 100 grade will be “I” (INVALID).

4

Page 5: GPA calculator and grading program in c++

Computer programming 1st assignment

4; when GPA is between 0 and 20 grade will be “F”.

**************************************************************

5