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.  
  13. double inv=20.0; double purchase=0; double balance=0; double interes=0.03;
  14.  
  15. double ganancia;
  16.  
  17.  
  18. for(int dia=2; dia<=25; dia++)
  19.  
  20. {
  21.  
  22. ganancia=interes*inv;
  23. purchase+=ganancia/2;
  24. balance+=ganancia/2;
  25.  
  26.  
  27.  
  28. if(purchase >=1.00 || balance>=1.00)
  29. {
  30.  
  31. purchase-=1;
  32. ++inv;
  33.  
  34. if(balance>=1.00)
  35. balance-=1;
  36. ++inv;
  37.  
  38. }
  39.  
  40. }
  41. System.out.println (inv);
  42. System.out.println ("balance:"+balance);
  43. System.out.println ("purchase:"+purchase);
  44. // your code goes here
  45. }
  46. }
Success #stdin #stdout 0.06s 2841600KB
stdin
Standard input is empty
stdout
38.0
balance:0.84
purchase:0.84