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.  
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. System.out.println("Кофе-машина");
  14.  
  15. int moneyAmount = 100;
  16.  
  17. int [] a = new int[3];
  18. String [] b = {
  19. "Капучино",
  20. "Американо",
  21. "Яблочный сок"
  22. };
  23. a[0] = 150;
  24. a[1] = 80;
  25. a[2] = 70;
  26. boolean canBuyAnything = false;
  27.  
  28. for(int i = 0; i<3; i++){
  29. if(moneyAmount >= a[i]) {
  30. System.out.println("Вы можете купить " + b[i]);
  31. canBuyAnything = true;
  32. }
  33. }
  34. if(canBuyAnything == false) {
  35. System.out.println("Недостаточно средств");
  36. }
  37. }
  38. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы можете купить Американо
Вы можете купить Яблочный сок