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. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. System.out.println("Кофе-машина");
  14.  
  15. int moneyAmount = 20;
  16.  
  17. System.out.println("Вы внесли " + moneyAmount + " руб.");
  18.  
  19. int cappucinoPrice = 170;
  20. int americanoPrice = 120;
  21. int lattePrice = 150;
  22. int milkPrice = 30;
  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 >= lattePrice) {
  36. System.out.println("Вы можете купить латте");
  37. canBuySomething = true;
  38. }
  39. if(moneyAmount >= milkPrice) {
  40. System.out.println("Вы можете купить молоко");
  41. canBuySomething = true;
  42. }
  43.  
  44. if(canBuySomething == false) {
  45. System.out.println("Недостаточно средств :( Изучайте Java и зарабатывайте много!");
  46. }
  47. }
  48. }
  49.  
Success #stdin #stdout 0.14s 57484KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы внесли 20 руб.
Недостаточно средств :( Изучайте Java и зарабатывайте много!