Skip to content

Commit cdc1507

Browse files
authored
Create gpa.cpp
0 parents  commit cdc1507

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

gpa.cpp

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#include <iostream>
2+
#include <stdlib.h>
3+
4+
using namespace std;
5+
6+
void calculateGPA();
7+
void calculateCGPA();
8+
9+
int main()
10+
{
11+
system("cls");
12+
int input;
13+
cout<<"--------------------------------------------------------------------------"<<endl;
14+
cout<<" GPA & CGPA Calculator (Developed by Ohid) "<<endl;
15+
cout<<"--------------------------------------------------------------------------\n"<<endl;
16+
cout<<" MENU:"<<endl;
17+
cout<<" 1. Calculate GPA (Grade Point Average)"<<endl;
18+
cout<<" 2. Calculate CGPA (Cummulative Grade Point Average)"<<endl;
19+
cout<<" 4. Exit Application"<<endl;
20+
cout<<"--------------------------------------------------------------------------"<<endl;
21+
sub:
22+
cout<<"Enter your choice: ";
23+
cin>>input;
24+
switch(input)
25+
{
26+
case 1:
27+
calculateGPA();
28+
break;
29+
30+
case 2:
31+
calculateCGPA();
32+
break;
33+
case 3:
34+
method();
35+
break;
36+
case 4:
37+
exit(EXIT_SUCCESS);
38+
break;
39+
default:
40+
cout<<"You have entered wrong input.Try again!\n"<<endl;
41+
goto sub;
42+
break;
43+
}
44+
}
45+
46+
void calculateGPA()
47+
{
48+
int q;
49+
system("cls");
50+
cout<<"-------------- GPA Calculating -----------------"<<endl;
51+
cout<<" How many subject's points do you want to calculate? : ";
52+
cin>>q;
53+
54+
float credit [q];
55+
float point [q];
56+
57+
cout<<endl;
58+
for(int i=0;i<q;i++)
59+
{
60+
cout<<"Enter the credit for the subject "<<i+1<<": ";
61+
cin>>credit[i];
62+
cout<<endl;
63+
cout<<"Enter the point of the subject "<<i+1<<": ";
64+
cin>>point[i];
65+
cout<<"-----------------------------------\n\n"<<endl;
66+
}
67+
68+
float sum=0;
69+
float tot;
70+
for(int j=0;j<q;j++)
71+
{
72+
tot=credit[j]*point[j];
73+
sum=sum+tot;
74+
}
75+
76+
float totCr=0;
77+
for(int k=0;k<q;k++)
78+
{
79+
totCr=totCr+credit[k];
80+
}
81+
82+
cout<<"\n\n\nTotal Points: "<<sum<<" . Total Credits: "<<totCr<<" .Total GPA: "<<sum/totCr<<" ."<<endl;
83+
84+
85+
sub:
86+
int inmenu;
87+
cout<<"\n\n\n1. Calculate Again"<<endl;
88+
cout<<"2. Go Back to Main Menu"<<endl;
89+
cout<<"3. Exit This App \n\n"<<endl;
90+
cout<<"Your Input: "<<endl;
91+
cin>>inmenu;
92+
93+
switch(inmenu)
94+
{
95+
case 1:
96+
calculateGPA();
97+
break;
98+
case 2:
99+
main();
100+
break;
101+
case 3:
102+
exit(EXIT_SUCCESS);
103+
104+
default:
105+
cout<<"\n\nYou have Entered Wrong Input!Please Choose Again!"<<endl;
106+
goto sub;
107+
}
108+
}
109+
void calculateCGPA()
110+
{
111+
system("cls");
112+
int l;
113+
cout<<"-------------- CGPA Calculating -----------------\n\n"<<endl;
114+
cout<<"How many semester results do you want input? :";
115+
cin>>l;
116+
cout<<"\n\n"<<endl;
117+
float semrs[l];
118+
int i;
119+
120+
for(i=0;i<l;i++)
121+
{
122+
cout<<" Enter Semester "<<i+1<<" Result(GPA): ";
123+
cin>>semrs[i];
124+
cout<<"\n"<<endl;
125+
}
126+
127+
float semtot=0;
128+
for(int j=0;j<l;j++)
129+
{
130+
semtot=semtot+semrs[j];
131+
}
132+
133+
cout<<"******** Your CGPA is "<<semtot/l<<" **********"<<endl;
134+
135+
136+
sub:
137+
int inmenu;
138+
cout<<"\n\n\n1. Calculate Again"<<endl;
139+
cout<<"2. Go Back to Main Menu"<<endl;
140+
cout<<"3. Exit This App \n\n"<<endl;
141+
cout<<"Your Input: "<<endl;
142+
cin>>inmenu;
143+
144+
switch(inmenu)
145+
{
146+
case 1:
147+
calculateCGPA();
148+
break;
149+
case 2:
150+
main();
151+
break;
152+
case 3:
153+
exit(EXIT_SUCCESS);
154+
155+
default:
156+
cout<<"\n\nYou have Entered Wrong Input!Please Choose Again!"<<endl;
157+
goto sub;
158+
}
159+
160+
}

0 commit comments

Comments
 (0)