fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.text.*;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scn = new Scanner(System.in);
  13. int loop;
  14. float temp,sum=0,num;
  15. while(scn.hasNext()){
  16. String[] str = scn.nextLine().split(" ");
  17. float[] arr = new float[str.length];
  18. for(loop=0;loop<str.length;loop++){
  19. temp = Integer.parseInt(str[loop]);
  20. arr[loop] = temp;
  21. sum += arr[loop];
  22. if(loop==(arr.length-1)){
  23. System.out.println(arr.length);
  24. sum /= arr.length;
  25. df.applyPattern("0.000");
  26. System.out.println(df.format(sum));
  27. sum = 0;
  28. }
  29. }
  30. }
  31. }
  32. }
Success #stdin #stdout 0.11s 35432KB
stdin
1 2 3
1 2 3
1 2 3
stdout
3
2.000
3
2.000
3
2.000