You are viewing a single comment's thread. Return to all comments →
simple java code from scratch
public static void plusMinus(List arr) { // Write your code here int plus=0,minus=0,zero=0,total=0; for(int x:arr) { if(x<0) minus++; else if(x==0) zero++; else if(x>0) plus++; total++; } double positive=(double)plus/total, negative=(double)minus/total, Zero=(double)zero/total; System.out.println(String.format("%.6f",positive)); System.out.println(String.format("%.6f",negative)); System.out.println(String.format("%.6f",Zero)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
simple java code from scratch
public static void plusMinus(List arr) { // Write your code here int plus=0,minus=0,zero=0,total=0; for(int x:arr) { if(x<0) minus++; else if(x==0) zero++; else if(x>0) plus++; total++;
} double positive=(double)plus/total, negative=(double)minus/total, Zero=(double)zero/total;
System.out.println(String.format("%.6f",positive)); System.out.println(String.format("%.6f",negative)); System.out.println(String.format("%.6f",Zero)); }