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. Scanner in = new Scanner(System.in);
  14. System.out.print("Назовите Ваш бюджет :)");
  15. int moneyAmount = in.nextInt();
  16. int cappucinoPrice = 150;
  17. int espressoPrice = 80;
  18. int waterPrice = 20;
  19. int milkPrice = 50;
  20.  
  21. boolean canBuyAnything = false;
  22.  
  23. if(moneyAmount >= cappucinoPrice) {
  24. System.out.println("Вы можете купить капучино");
  25. canBuyAnything = true;
  26. }
  27.  
  28. if(moneyAmount >= espressoPrice) {
  29. System.out.println("Вы можете купить эспрессо");
  30. canBuyAnything = true;
  31. }
  32.  
  33. if(moneyAmount >= waterPrice) {
  34. System.out.println("Вы можете купить воду");
  35. canBuyAnything = true;
  36. }
  37. if(moneyAmount >= milkPrice) {
  38. System.out.println("Вы можете купить молоко");
  39. canBuyAnything = true;
  40. }
  41. if(canBuyAnything == false) {
  42. System.out.println("Недостаточно средств :( Изучайте Java и зарабатывайте много!))");
  43. }
  44. }
  45. }
Success #stdin #stdout 0.1s 35364KB
stdin
70
stdout
Кофе-машина
Назовите Ваш бюджет :)Вы можете купить воду
Вы можете купить молоко