fork(3) 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. // your code goes here
  13. System.out.println("Кофе-машина");
  14. int moneyAmount = 2;
  15.  
  16. Map<String, Integer> hashMap = new HashMap<String, Integer>();
  17. hashMap.put("Капучино", 150);
  18. hashMap.put("Американо", 80);
  19. hashMap.put("Сок", 70);
  20. hashMap.put("Молоко", 50);
  21. hashMap.put("Вода", 10);
  22.  
  23. boolean canBuyAnything = false;
  24.  
  25.  
  26. for (Map.Entry entry : hashMap.entrySet()) {
  27. if (moneyAmount >= (int) entry.getValue()) {
  28. System.out.println("Вы можете купить " + entry.getKey());
  29. canBuyAnything = true;
  30. }
  31. }
  32. if(canBuyAnything == false) {
  33. System.out.println("Недостаточно средств");
  34. }
  35.  
  36. }
  37. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
Кофе-машина
Недостаточно средств