-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluss_minus.java
More file actions
36 lines (30 loc) · 859 Bytes
/
pluss_minus.java
File metadata and controls
36 lines (30 loc) · 859 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
29
30
31
32
33
34
35
36
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
//solution to: https://www.hackerrank.com/challenges/plus-minus
public class pluss_minus {
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 scan = new Scanner(System.in);
int n = scan.nextInt();
float positive = 0;
float negative = 0;
float zeroes = 0;
int[]inputs = new int[n];
for(int i = 0; i < inputs.length; i++){
inputs[i] = scan.nextInt();
if(inputs[i] > 0){
positive++;
}else if(inputs[i] < 0){
negative++;
}else if(inputs[i] == 0){
zeroes++;
}
}
System.out.println(positive/n);
System.out.println(negative/n);
System.out.println(zeroes/n);
}
}