-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudentDetails.java
51 lines (46 loc) · 1.4 KB
/
studentDetails.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
public class studentDetails {
public static void main(String[] args) {
System.out.println();
}
}
class student{
String id_no;
int no_of_subject;
String subject_name [] = {"MATHS", "C" , "PHYSICS" , "DF" , "IC" , "ES"};
int subject_credits [] = {6,6,5,5,2,2};
String gread_obtain [] = {"A+" , "A" , "A+" , "B+" , "C" , "B"};
double spi;
void calculate_spi(){
int totalcredit=0;
for(int i = 0; i < 6; i++){
switch(gread_obtain[i]){
case("A+"): {
totalcredit += 10 * subject_credits[i];
break;
}
case("A"): {
totalcredit += 9 * subject_credits[i];
break;
}
case("B+"): {
totalcredit += 8 * subject_credits[i];
break;
}
case("B"): {
totalcredit += 7 * subject_credits[i];
break;
}
case("C+"): {
totalcredit += 6 * subject_credits[i];
break;
}
case("C"): {
totalcredit += 5 * subject_credits[i];
break;
}
}
}
double totalspi = totalcredit / 26;
System.out.println(totalspi);
}
}