-
Notifications
You must be signed in to change notification settings - Fork 8
/
PointsClassReloaded.java
56 lines (53 loc) · 1.69 KB
/
PointsClassReloaded.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
import java.util.ArrayList;
/**
*
* @author giuseppedesantis
*/
public class Points {
private ArrayList<Integer> points;
int accepted;
int zeros;
public Points(ArrayList<String> gradesInString){
this.points = new ArrayList<Integer>();
for(String g : gradesInString){
int points = Integer.parseInt(g);
if (points >= 0 && points <= 29){
this.points.add(0);
this.zeros++;
}else if (points <= 34 && points >= 30){
this.points.add(1);
this.accepted++;
}else if (points <= 39 && points >= 35){
this.points.add(2);
this.accepted++;
}else if (points <= 44 && points >= 40){
this.points.add(3);
this.accepted++;
}else if (points <= 49 && points >= 45){
this.points.add(4);
this.accepted++;
}else if (points <= 60 && points >= 50){
this.points.add(5);
this.accepted++;
}
}
}
public void pointsStats(){
System.out.println("Grade distribution:");
for(int i = 5; i >= 0; i--){
System.out.print(i+": ");
for(int points : this.points){
if(points == i){
System.out.print("*");
}
}
System.out.println("");
}
}
public void acceptancePercentage(){
double allScores = (double)(this.accepted + this.zeros);
double accepted = (double)(this.accepted);
double acceptancePercentage = 100*accepted/allScores;
System.out.println("Acceptance percentage: "+ acceptancePercentage);
}
}