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)
  11. {
  12. int milesDriven = 50000;
  13. int mpg1 = 10;
  14. int mpg2 = 50;
  15. int pricePerGallon = 4;
  16. int purchasePrice1 = 15000;
  17. int purchasePrice2 = 30000;
  18. int gasCost4Car1 = (milesDriven / mpg1) * pricePerGallon;
  19. int gasCost4Car2 = (milesDriven / mpg2) * pricePerGallon;
  20. int total4Car1 = (purchasePrice1 + gasCost4Car1);
  21. int total4Car2 = (purchasePrice2 + gasCost4Car2);
  22.  
  23. if(total4Car1 < total4Car2)
  24. {
  25. System.out.println(total4Car1);
  26. } else {
  27. System.out.println(total4Car2);
  28. }
  29. }
  30. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
34000