fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int n, negative=0;
  11. double sum=0;
  12. n = in.nextInt();
  13. double numberArray[] = new double [n];
  14. for(int i=0; i<n; i++)
  15. {
  16. numberArray[i] = in.nextDouble();
  17. if (numberArray[i]<0) negative++;
  18. else sum+=numberArray[i];
  19. }
  20. System.out.print("Negative numbers: " + negative + " The sum of positive numbers: " + sum);
  21. }
  22. }
Success #stdin #stdout 0.17s 321344KB
stdin
14
1 2 -4.2 3.5 6.2 8 11 -144 288 9.2 -22 12 -13.5 14
stdout
Negative numbers: 4  The sum of positive numbers: 354.9