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