-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpa.cpp
More file actions
66 lines (55 loc) · 1.23 KB
/
Copy pathgpa.cpp
File metadata and controls
66 lines (55 loc) · 1.23 KB
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
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int totalSubjects;
cout << "Enter the total number of subjects: ";
cin >> totalSubjects;
int totalCredits = 0;
int totalGradePoints = 0;
cout << "\nEnter details for each subject:\n";
for (int i = 1; i <= totalSubjects; ++i)
{
double marks, credits;
cout << "\nEnter marks for subject " << i << " out of 100: ";
cin >> marks;
cout << "Enter credits for subject " << i << ": ";
cin >> credits;
totalCredits += credits;
double gradePoints;
if (marks >= 90)
{
gradePoints = 10;
}
else if (marks >= 80)
{
gradePoints = 9;
}
else if (marks >= 70)
{
gradePoints = 8;
}
else if (marks >= 60)
{
gradePoints = 7;
}
else if (marks >= 50)
{
gradePoints = 6;
}
else if (marks >= 40)
{
gradePoints = 5;
}
else
{
gradePoints = 0;
}
totalGradePoints += gradePoints * credits;
}
int GPA = totalGradePoints / totalCredits;
cout << "\nTotal Credits: " << totalCredits << endl;
cout << "GPA out of 10: " << GPA << endl;
return 0;
}