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