-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpa.cpp
More file actions
50 lines (38 loc) · 1.09 KB
/
Copy pathgpa.cpp
File metadata and controls
50 lines (38 loc) · 1.09 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
#include <iostream>
#include <string>
using namespace std;
int main() {
string name;
int numSubjects;
float totalUnits = 0, totalGrade = 0;
cout << "Enter Student Name: ";
getline(cin, name);
cout << "Enter Number of Subjects: ";
cin >> numSubjects;
for (int i = 0; i < numSubjects; i++) {
string subject;
float grade, units;
cout << "Enter Subject " << i + 1 << ": ";
cin.ignore();
getline(cin, subject);
cout << "Enter Grade (1.0 - 5.0): ";
cin >> grade;
cout << "Enter Units: ";
cin >> units;
totalUnits += units;
totalGrade += grade * units;
}
float gpa = totalGrade / totalUnits;
cout << "Student Name: " << name << endl;
cout << "GPA: " << gpa << endl;
if (gpa >= 1.0 && gpa <= 1.75) {
cout << "Dean's Lister" << endl;
} else if (gpa >= 1.76 && gpa <= 2.5) {
cout << "Good Standing" << endl;
} else if (gpa >= 2.51 && gpa <= 3.0) {
cout << "Probation" << endl;
} else {
cout << "Failed" << endl;
}
return 0;
}