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