-
Notifications
You must be signed in to change notification settings - Fork 111
/
solution.java
38 lines (34 loc) · 945 Bytes
/
solution.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
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class solution {
// main function
public static void main(String[] args) {
// getting size
Scanner scan = new Scanner(System.in);
int size = scan.nextInt();
// Count instances of +,-,0
double positives = 0;
double negatives = 0;
double zeroes = 0;
for (int i = 0; i < size; i++) {
int value = scan.nextInt();
if (value > 0) {
positives++;
} else if (value < 0) {
negatives++;
} else {
zeroes++;
}
}
scan.close();
// Print ratios
System.out.println(positives / size);
System.out.println(negatives / size);
System.out.println(zeroes / size);
}
}