-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
48 lines (42 loc) · 1.1 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
import java.util.ArrayList;
import java.util.Scanner;
public class Student {
String name;
ArrayList<Integer> grades;
Scanner s = new Scanner(System.in);
public Student(String name){
this.name = name;
ArrayList<Integer> grades = new ArrayList<Integer>();
}
public Double studentAvg(){
double sum = 0;
for (int i:grades) {
sum += grades.get(i);
}
return sum/grades.size();
}
public Boolean isTop(){
if (studentAvg()>=90) {
return true;
} else {
return false;
}
}
public Student better(Student other){
Student x = new Student(s.next());
if (x.studentAvg() > other.studentAvg()) {
return x;
} else {
return other;
}
}
public ArrayList<Integer> failures() {
ArrayList<Integer> failed = new ArrayList<Integer>();
for (int i:grades) {
if (grades.get(i)<55){
failed.add(grades.get(i));
}
}
return failed;
}
}