-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGP.cpp
68 lines (49 loc) · 1.8 KB
/
CGP.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
#include <iostream>
#include <stdlib.h>
//BULIDNG A GPA CALCULATOR
using namespace std;
void gpa();
int main()
{
cout << "----------- GPA CALCULATOR ----------" << endl;
void gpa();
{
int A = 5; //INITIALITING ALPHABETS TO NUMBERS//NOT WORKING YET THOU
int B = 4;
int C = 3;
int D = 2;
int E = 1;
int F = 0;
int q; // for the input
cout<<"------------ GPA calculating ------------ "<<endl;
cout<<" how many subjects do you want to calculate? : "; //THIS WOULD CREATE A TABLE FOR ALL THE SUBJECTS TO BE CALCULATED
cin>>q; //TAKES INPUT FROM THE USER
float GRADE [q]; // TO CALCULATGE THE GRADE IN DECIMALS
float point [q]; // TO CALCULATE THE POINTS IN DECIMALS
cout<<endl;
for(int i=0;i<q;i++) // IF DECISION, IF I IS ZERO THEN I IS LESS THAN Q AND I SHOULD BE ADDED BY ONE
{
//THIS IS FOR THE TOTAL SUBJECTS TO BE ADDED
cout<<"Enter the Grade for the subject "<<i+1<<": ";
cin>>GRADE [i]; //INPUT FROM THE USER FOR THE GRADE
cout<<endl; // FOR SPACING
cout<<"Enter the point of the subject "<<i+1<<": ";
cin>>point[i]; // THE USER POINT
cout<<"-----------------------------------\n\n"<<endl; //THE END OF ONE OR MORE SUBJECT
}
//FOR THE GPA AND CGPA CALCULATION
float sum=0; //to get sum in decimal
float total; // grade multiply sum to get total
for(int j=0;j<q;j++)
{
total=GRADE[j]*point[j];
sum=sum+total;
}
float totalCredit=0; //
for(int k=0;k<q;k++)
{
totalCredit=totalCredit+GRADE[k]; //SUM FOR ALL TOTAL CREDIT
}
cout<<"\n\n\nTotal Points: "<<sum<<" . Total GRADE: "<<totalCredit<<" .Total GPA: "<<sum/totalCredit<<" ."<<endl;
}
}