fork download
  1. public class Main
  2. {
  3. public static void main(String[] args)
  4. {
  5. System.out.println("Кофе-машина");
  6.  
  7. int moneyAmount = 120;
  8. System.out.println("Вы внесли: " + moneyAmount + "рублей");
  9.  
  10. int cappucinoPrice = 150;
  11. int espressoPrice = 80;
  12. int waterPrice = 20;
  13.  
  14. boolean canBuySomething = false;
  15.  
  16. if (moneyAmount >= cappucinoPrice) {
  17. System.out.println("Вы можете купить капучино");
  18. canBuySomething = true;
  19. }
  20.  
  21. if (moneyAmount >= espressoPrice) {
  22. System.out.println("ВЫ можете купить экспрессо");
  23. canBuySomething = true;
  24. }
  25.  
  26. if (moneyAmount >= waterPrice) {
  27. System.out.println("Вы можете купить воду");
  28. canBuySomething = true;
  29. }
  30.  
  31. if (canBuySomething == false) {
  32. System.out.println("Недостаточно средств!");
  33. }
  34. }
  35. }
  36.  
Success #stdin #stdout 0.09s 35948KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы внесли: 120рублей
ВЫ можете купить экспрессо
Вы можете купить воду