fork(8) 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. System.out.println("Кофе-машина");
  13.  
  14. int moneyAmount = 90;
  15.  
  16. String drinkNames[] = {"капучино", "эспрессо", "вода", "чай"};
  17. int drinkPrices[] = {140, 80, 20, 40};
  18.  
  19. boolean canBuyAnything = false;
  20. for(int i = 0; i < drinkNames.length; i = i + 1)
  21. {
  22. if(moneyAmount >= drinkPrices[i]) {
  23. System.out.println("Вы можете купить " + drinkNames[i]);
  24. canBuyAnything = true;
  25. }
  26. }
  27.  
  28. if(!canBuyAnything) {
  29. System.out.println("Внесите ещё немного денег");
  30. }
  31. }
  32. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы можете купить эспрессо
Вы можете купить вода
Вы можете купить чай