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 = 146;
  12.  
  13. int espressoPrice = 60;
  14. int cappucinoPrice = 120;
  15. int waterPrice = 20;
  16. int latteePrice = 100;
  17.  
  18. //======================================================
  19.  
  20. boolean canBuyAnything = false;
  21.  
  22. if(moneyAmount >= cappucinoPrice)
  23. {
  24. System.out.println("Вы можете купить капучино");
  25. canBuyAnything = true;
  26. }
  27.  
  28. if(moneyAmount >= waterPrice)
  29. {
  30. System.out.println("Вы можете купить воду");
  31. canBuyAnything = true;
  32. }
  33.  
  34. if(moneyAmount >= espressoPrice)
  35. {
  36. System.out.println("Вы можете купить эспрессо");
  37. canBuyAnything = true;
  38. }
  39. if(moneyAmount >= latteePrice)
  40. {
  41. System.out.println("Вы можете купить латте");
  42. canBuyAnything = true;
  43. }
  44.  
  45. if(!canBuyAnything) {
  46. System.out.println("Недостаточно средств :(");
  47. }
  48. }
  49. }
Success #stdin #stdout 0.05s 27776KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы можете купить капучино
Вы можете купить воду
Вы можете купить эспрессо
Вы можете купить латте