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