-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChoices.java
More file actions
28 lines (24 loc) · 840 Bytes
/
Choices.java
File metadata and controls
28 lines (24 loc) · 840 Bytes
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
// LSK-ChoiceFmt/Choices.java
import java.text.ChoiceFormat;
import java.util.Random;
import static java.lang.Math.min;
import static java.lang.Math.max;
public class Choices {
public static void main(String[] args) {
ChoiceFormat chform = new ChoiceFormat(
new double[]{
Double.NEGATIVE_INFINITY,50,60,70,80,
},
new String[]{
"failing", "passing", "average",
"good", "excellent",
});
Random rng = new Random(System.currentTimeMillis());
for (int i = 0; i < 40; ++i) {
double grade =
max(0,min(15*rng.nextGaussian()+60,100));
System.out.printf("%5.2f -> %s%n",grade,
chform.format(grade));
}
}
}