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