fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. System.out.println("Кофе-машина");
  10.  
  11. int moneyAmount = 35;
  12.  
  13. int cappucinoPrice = 120;
  14. int espressoPrice = 80;
  15. int waterPrice = 20;
  16. int milkPrice = 35;
  17.  
  18. boolean canBuyAnything = false;
  19.  
  20. if(cappucinoPrice <= moneyAmount) {
  21. System.out.println("Вы можете купить капучино!");
  22. canBuyAnything = true;
  23. }
  24.  
  25. if(espressoPrice <= moneyAmount) {
  26. System.out.println("Вы можете купить эспрессо!");
  27. canBuyAnything = true;
  28. }
  29.  
  30. if(waterPrice <= moneyAmount) {
  31. System.out.println("Вы можете купить воду!");
  32. canBuyAnything = true;
  33. }
  34. if(milkPrice <= moneyAmount) { // проверка доступности покупки молока
  35. System.out.println("Вы можете купить молоко!");
  36. canBuyAnything = true;
  37. }
  38.  
  39. if(!canBuyAnything) {
  40. System.out.println("Вы не можете ничего купить! Учите джаву и идите работать!");
  41. }
  42. }
  43. }
Success #stdin #stdout 0.08s 27668KB
stdin
Standard input is empty
stdout
Кофе-машина
Вы можете купить воду!
Вы можете купить молоко!