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