-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourseList.java
66 lines (41 loc) · 1.99 KB
/
CourseList.java
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
package com.sharetechidea.srms;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CourseList {
List<Course> courses = new ArrayList<Course>();
double totalGPA;
boolean isInitial = true;
Map<Course,String> grades = new HashMap<>();
Map<String,String> idgrade = new HashMap<>();
void findGPA(Course course,String grade){
grades.put(course,grade);
totalGPA = 0;
int courseCredits=0;
double points;
for (Map.Entry<Course, String> entry : grades.entrySet()) {
System.out.println(entry.getValue());
if(entry.getValue().equals("")) points=0;
else if(entry.getValue().equals("A+")) points=4;
else if(entry.getValue().equals("A")) points=3.7;
else if(entry.getValue().equals("A-")) points=3.3;
else if(entry.getValue().equals("B+")) points=3;
else points=3;
if(points!=0){
courseCredits=courseCredits+entry.getKey().getCourseCredits();
}
points = points*entry.getKey().getCourseCredits();
totalGPA=totalGPA+points;
System.out.println("Total Gpa is "+ totalGPA);
System.out.println("Course Credit is "+ courseCredits);
}
totalGPA=totalGPA/courseCredits;
}
void saveGrades(String sem){
for (Map.Entry<Course, String> entry : grades.entrySet()) {
idgrade.put(entry.getKey().getCourseId(),entry.getValue());
}
FirebaseServices.saveCourseGrades(idgrade,sem);
}
}