You are on page 1of 3

#include<iostream>

using namespace std;


float g();
float cal();
int list();
void main()
{
int u, i;
cout << "============================================" << endl;
cout << "\t\tWelcome To CGPA Calculator " << endl;
cout << "============================================" << endl;
cout << "1.GPA Calculator " << endl;
cout << "2.CGPA Calculator " << endl;
cout << "3.Grades List " << endl;
cout << "Select" << endl;
cin >> u;
if (u == 1)
{
cout << "Your GPA is : " << g() << endl;
}
else if (u == 2)
{
cout << "Your CGPA is : " << cal() << endl;
}
else if (u == 3)
{
list();
}
else
{
cout << "You Enter Invalid Number " << endl;
}
cout << "\n----------------------------------------------" << endl;
cout << "\n CS-IDIOTS. All Rights Reserved.\n" << endl;
cout << "----------------------------------------------" << endl;
system("pause");
}
float g()
{
int i;
int crh[7], tcr = 0;
float gp = 0.0, gpa;
cout << "Enter a Number of Subjects : " << endl;
cin >> i;
float c[7], gr[7];
float AP = 4.0, A = 3.70, BP = 3.40, B = 3.00, BN = 2.5, CP = 2.00, C = 1.50, D =
1.00, F = 0.00;
for (int j = 1; j <= i; j++)
{
cout << " Enter a Number of Subject of : " << j << endl;
cin >> c[j];
cout << "Enter Credit Hour of Subject No. : " << j << endl;
cin >> crh[j];
if (c[j] >= 84.50 && c[j] <= 100)
{
gr[j] = AP;
}
else if (c[j] < 84.49 && c[j] >= 79.50)
{
gr[j] = A;
}
else if (c[j] < 79.49 && c[j] >= 74.50)
{
gr[j] = BP;
}
else if (c[j] < 74.49 && c[j] >= 69.50)
{
gr[j] = B;
}
else if (c[j] < 69.49 && c[j] >= 64.50)
{
gr[j] = BN;
}
else if (c[j] < 64.49 && c[j] >= 59.50)
{
gr[j] = CP;
}
else if (c[j] < 59.49 && c[j] >= 54.50)
{
gr[j] = C;
}
else if (c[j] < 54.49 && c[j] >= 49.50)
{
gr[j] = D;
}
else
{
gr[j] = F;
}
gp = crh[j] * gr[j] + gp;
tcr = crh[j] + tcr;
}
gpa = gp / tcr;
return gpa;
}
float cal()
{
int m;
cout << "Enter Number of Semester : " << endl;
cin >> m;
int cr[8], t = 0;
float gpac[8], gpc = 0.0, cgpa;
for (int l = 1; l <= m; l++)
{
cout << "Enter a GPA of Semester of : " << l << endl;
cin >> gpac[l];
cout << "Enter a Credit Hours of Semester of : " << l << endl;
cin >> cr[l];
gpc = gpc + gpac[l] * cr[l];
t = t + cr[l];
}
cgpa = gpc / t;

return cgpa;
}
int list()
{
cout << "Marks Percentage\tGrade\tPoints\tStatus" << endl;
cout << "84.50 and Above\t\tA+\t4.00\tExceptional" << endl;
cout << "79.50-84.49\t\tA\t3.70\tOutstanding" << endl;
cout << "74.50-79.49\t\tB+\t3.40\tExcellent" << endl;
cout << "69.50-74.49\t\tB\t3.00\tVery Good" << endl;
cout << "64.50-69.49\t\tB-\t2.50\tGood" << endl;
cout << "59.50-64.49\t\tC+\t2.00\tAverage" << endl;
cout << "54.50-59.49\t\tC\t1.50\tSatisfactory" << endl;
cout << "49.50-54.49\t\tD\t1.00\tPass" << endl;
cout << "Below 49.50\t\tF\t0.00\tFail" << endl;
return 1;
}

You might also like