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