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