fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  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. // your code goes here
  13. int A=12,B=20;
  14. int numOfFives=A/5;
  15. int remainder=A%5;
  16.  
  17. double sum=0;
  18. // double qwe=5/12;
  19. //System.out.println(6d/12d);
  20. for(int i=0;i<numOfFives;i++){
  21. sum+=B*(5d/12d);
  22. System.out.println(sum);
  23. }
  24. sum+=B*(remainder/12d);
  25. System.out.println("Final Sum ="+sum);
  26.  
  27. System.out.println("Sequence = ");
  28. for(int i=0;i<numOfFives;i++){
  29. System.out.println(5+",");
  30. }
  31. System.out.println(remainder);
  32. }
  33. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
8.333333333333334
16.666666666666668
Final Sum =20.0
Sequence = 
5,
5,
2