-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourse.java
103 lines (77 loc) · 2.58 KB
/
Course.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
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
package Project.CGPA;
public class Course {
private String name = "";
private double credit = 0.0;
private double grade;
private String letterGrade = "";
private static double totalCreditEarned = 0;
public Course() {
}
public Course(String name, double credit, double grade) {
this.name = name;
this.credit = credit;
this.grade = grade;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getCredit() {
return credit;
}
public void setCredit(double credit) {
this.credit = credit;
}
public double getGrade() {
return grade;
}
public void setGrade(int grade) {
switch (grade) {
case 0 -> this.grade = 4.0;
case 1 -> this.grade = 3.7;
case 2 -> this.grade = 3.3;
case 3 -> this.grade = 3.0;
case 4 -> this.grade = 2.7;
case 5 -> this.grade = 2.3;
case 6 -> this.grade = 2.0;
case 7 -> this.grade = 1.7;
case 8 -> this.grade = 1.3;
case 9 -> this.grade = 1.0;
case 10 -> this.grade = 0;
}
}
public String getLetterGrade() {
return letterGrade;
}
public void setLetterGrade(int grade) {
switch (grade) {
case 0 -> this.letterGrade = "A";
case 1 -> this.letterGrade = "A-";
case 2 -> this.letterGrade = "B+";
case 3 -> this.letterGrade = "B";
case 4 -> this.letterGrade = "B-";
case 5 -> this.letterGrade = "C+";
case 6 -> this.letterGrade = "C";
case 7 -> this.letterGrade = "C-";
case 8 -> this.letterGrade = "D+";
case 9 -> this.letterGrade = "D";
case 10 ->this.letterGrade = "F";
}
}
public static double getTotalCreditEarned() {
return totalCreditEarned;
}
public static void setTotalCreditEarned(double totalCreditEarned) {
Course.totalCreditEarned = totalCreditEarned;
}
public String toString() {
return "\n " + name +
" " + credit +
" " + grade +
" " + letterGrade +
"\n----------------------------------------------------------------------------------------------"
;
}
}