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. int moneyAmount = 50;
  13. boolean notEnoughtMoney = false;
  14. TreeMap<Integer,String> menu = new TreeMap<Integer, String>();
  15. menu.put(140,"Латте");
  16. menu.put(160,"Капучино");
  17. menu.put(20,"Вода");
  18. menu.put(40,"Молоко");
  19.  
  20. for (Map.Entry<Integer,String> item:menu.entrySet()){
  21. if (item.getKey()<=moneyAmount){
  22. System.out.println("Вы можете купить "+item.getValue());
  23. notEnoughtMoney=true;
  24. }}
  25.  
  26. if(!notEnoughtMoney)
  27. System.out.println("У вас не достаточно денег");
  28.  
  29.  
  30. }
  31. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
Вы можете купить Вода
Вы можете купить Молоко