forked from RyanFehr/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.java
28 lines (24 loc) · 842 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
//Problem: https://www.hackerrank.com/challenges/plus-minus
//Java 8
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner input = new Scanner(System.in);
int n = input.nextInt();
double positive = 0;
double negative = 0;
double zero = 0;
for(int i = 0; i<n; i++)
{
int value = input.nextInt();
positive += value>0 ? 1:0;
negative += value<0 ? 1:0;
zero += value==0 ? 1:0;
}
System.out.println(positive/n);
System.out.println(negative/n);
System.out.println(zero/n);
}
}