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