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