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. int moneyAmount = 10;
  10.  
  11.  
  12. System.out.println("Кофе-машина");
  13.  
  14. int mineralWaterPrice = 20;
  15. int teaPrice = 45;
  16. int americanoPrice = 110;
  17. int cappucinoPrice = 150;
  18. int milkPrice = 160;
  19. boolean canBuyAnything = false;
  20.  
  21. if(moneyAmount >= mineralWaterPrice) {
  22. System.out.println("Вы можете купить минеральную воду");
  23. canBuyAnything = true;
  24. }
  25.  
  26. if(moneyAmount >= teaPrice) {
  27. System.out.println("Вы можете купить чай");
  28. canBuyAnything = true;
  29. }
  30.  
  31. if(moneyAmount >= americanoPrice) {
  32. System.out.println("Вы можете купить американо");
  33. canBuyAnything = true;
  34. }
  35.  
  36. if(moneyAmount >= cappucinoPrice) {
  37. System.out.println("Вы можете купить капучино");
  38. canBuyAnything = true;
  39. }
  40. if(moneyAmount >= milkPrice) {
  41. System.out.println("Вы можете купить молоко");
  42. canBuyAnything = true;
  43. }
  44. if(!canBuyAnything) {
  45. System.out.println("Недостаточно средств! Учите джаву и идите работать!");
  46. }
  47. }
  48. }
  49.  
Success #stdin #stdout 0.1s 27836KB
stdin
Standard input is empty
stdout
Кофе-машина
Недостаточно средств! Учите джаву и идите работать!