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 = 70;
  15.  
  16. System.out.println("Вы внесли " + moneyAmount + " руб.");
  17.  
  18. int cappucinoPrice = 150;
  19. int americanoPrice = 65;
  20. int waterPrice = 20;
  21. int milkPrice = 55;
  22.  
  23. boolean canBuySomething = false;
  24.  
  25. if(moneyAmount >= cappucinoPrice) {
  26. System.out.println("Вы можете купить капучино");
  27. canBuySomething = true;
  28. }
  29.  
  30. if(moneyAmount >= americanoPrice) {
  31. System.out.println("Вы можете купить американо");
  32. canBuySomething = true;
  33. }
  34.  
  35. if(moneyAmount >= waterPrice) {
  36. System.out.println("Вы можете купить воду");
  37. canBuySomething = true;
  38. }
  39.  
  40.  
  41. if(moneyAmount >= milkPrice) {
  42. System.out.println("Вы можете купить молоко");
  43. canBuySomething = true;
  44. }
  45. if(canBuySomething == false) {
  46. System.out.println("Недостаточно средств :( Изучайте Java и зарабатывайте много!))");
  47. }
  48. }
  49. }
Success #stdin #stdout 0.12s 35780KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы внесли 70 руб.
Вы можете купить американо
Вы можете купить воду
Вы можете купить молоко