fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. System.out.println("Кофе-машина");
  10.  
  11. int moneyAmount = 130;
  12.  
  13. int waterPrice = 20;
  14. int espressoPrice = 60;
  15. int cappucinoPrice = 120;
  16. int lattePrice = 130;
  17.  
  18. boolean canBuyAnything = false;
  19.  
  20. if(moneyAmount >= waterPrice) {
  21. System.out.println("Вы можете купить воду");
  22. canBuyAnything = true;
  23. }
  24.  
  25. if(moneyAmount >= espressoPrice) {
  26. System.out.println("Вы можете купить эспрессо");
  27. canBuyAnything = true;
  28. }
  29.  
  30. if(moneyAmount >= cappucinoPrice) {
  31. System.out.println("Вы можете купить капучино");
  32. canBuyAnything = true;
  33. }
  34.  
  35. if(moneyAmount >= lattePrice) {
  36. System.out.println("Вы можете купить латте");
  37. }
  38. if(!canBuyAnything) {
  39. System.out.println("Недостаточно средств");
  40. }
  41. }
  42. }
Success #stdin #stdout 0.05s 27696KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы можете купить воду
Вы можете купить эспрессо
Вы можете купить капучино
Вы можете купить латте