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 = 100;
  12.  
  13. int espressoPrice = 50;
  14. int lattePrice = 110;
  15. int cacaoPrice = 75;
  16. int milkPrice = 25;
  17. int waterPrice = 10;
  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.  
  43. if(moneyAmount >= waterPrice) {
  44. canBuyAnything = true;
  45. System.out.println("Вы можете купить воду");
  46. }
  47.  
  48. if(!canBuyAnything) {
  49. System.out.println("Недостаточно средств! внесите ещё!!!");
  50. }
  51. }
  52. }
Success #stdin #stdout 0.06s 27932KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы можете купить эспрессо
Вы можете купить какао
Вы можете купить молоко
Вы можете купить воду