Tuesday 26 July 2016

C++ GPA CALCULATOR

Step # 1 

first you have to view my previous program that is basic C++ GPA calculator available on following link

C++ GPA Calculator

Step # 2

this program is consists of following attributes.
1) pointer array.
2) function call by value & inline function.

i dont want to describe program briefly this program is consisted of  question as under

User is asked to enter 3 subject marks out of 100 

marks greater then 88 but less then 100 award grade must be A with 4.00 points
marks greater then 80 but less then 87 award grade must be B+ with 3.50 points
marks greater then 73 but less then 79 award grade must be B with 3.00 points
marks greater then 66 but less then 72 award grade must be C+ with 2.50 points
marks greater then 60 but less then 66 award grade must be C with 2.00 points
marks greater then 50 but less then 59 award grade must be D with 4.00 points
else you are fail in course

according to above brief option logic is simple 


Code:-


#include<iostream>

#include<conio.h>

using namespace std;



float getGpa(float *marks,float *subjects)

{
float result = 0;

for (int i = 0; i < 3; i++)
{
float points = 0;
if ((*marks + i)>=87)
{
points = 4;
}
else if ((*marks + i) >= 80 && (*marks + i) < 87)
{
points = 3.5;
}

else if ((*marks + i)>=72 && (*marks + i) < 80)

{
points = 3.0;
}
else if ((*marks + i)>=66 && (*marks + i) < 72)
{
points = 2.5;
}
else if ((*marks + i) >= 60 && (*marks + i) < 66)
{
points = 2.0;
}
else
{
points = 0;
}


result += points;

}

float ab;

ab = (result / 3);
return ab;
}


void main()

{
float marks[3];
float credits[3];
float *ptr;
float *_ptr;
for (int i = 0; i < 3; i++)
{
cout << "Enter marks of subject number " << i << " = ";
cin >> marks[i];

cout << "Enter credit of subject number " << i << " = ";
cin >> credits[i];
}

ptr = marks; _ptr = credits;

cout << "Gpa is = " << getGpa(ptr, _ptr);
_getch();
}


OUTPUT





ALL RIGHTS RESERVED TO UMAR JAVED 

c# , c++ , WORDPRESS , XAMARIN DEVELOPER