-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
77 lines (61 loc) · 1.48 KB
/
Student.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
public class Student {
private int id;
private String name;
private int[] marks;
private float average;
private char grade;
public Student(int id, String name, int[] marks) {
this.id = id;
this.name = name;
this.marks = marks;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int[] getMarks() {
return marks;
}
public void setMarks(int[] marks) {
this.marks = marks;
}
public float getAverage() {
return average;
}
public void setAverage(float average) {
this.average = average;
}
public char getGrade() {
return grade;
}
public void setGrade(char grade) {
this.grade = grade;
}
public void calculateAvg() {
int total = 0;
for (int mark : marks) {
total += mark;
}
average = (float) total / (float) marks.length;
}
public void findGrade() {
if (average <= 100 && average >= 80) {
grade = 'O';
} else if (average < 80 && average >= 50) {
grade = 'A';
}
for (int mark : marks) {
if (mark < 50) {
grade = 'F';
}
}
}
}