Skip to content

Commit 3c64cd7

Browse files
Create main.cpp
1 parent 3fcbc12 commit 3c64cd7

File tree

1 file changed

+196
-0
lines changed
  • Projects/C++ Projects/Basic/Calculate CGPA and GPA

1 file changed

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

0 commit comments

Comments
 (0)