fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Scanner;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. System.out.println("Кофе-машина");
  14.  
  15. System.out.println("Введите деньги");
  16. Scanner sc = new Scanner(System.in);
  17. int moneyAmount = sc.nextInt();
  18. sc.close();
  19.  
  20.  
  21. int cappucinoPrice = 150;
  22. int espressoPrice = 80;
  23. int waterPrice = 20;
  24. int milkPrice = 50;
  25.  
  26. boolean canBuyAnything = false;
  27.  
  28. if(moneyAmount >= cappucinoPrice) {
  29. System.out.println("Вы можете купить капучино");
  30. canBuyAnything = true;
  31. }
  32.  
  33. if(moneyAmount >= espressoPrice) {
  34. System.out.println("Вы можете купить эспрессо");
  35. canBuyAnything = true;
  36. }
  37.  
  38. if(moneyAmount >= waterPrice) {
  39. System.out.println("Вы можете купить воду");
  40. canBuyAnything = true;
  41. }
  42.  
  43. if(moneyAmount >= milkPrice) {
  44. System.out.println("Вы можете купить молоко");
  45. canBuyAnything = true;
  46. }
  47.  
  48. if(canBuyAnything == false) {
  49. System.out.println("Недостаточно средств :( Изучайте Java и зарабатывайте много!))");
  50. }
  51. }
  52. }
Success #stdin #stdout 0.1s 35480KB
stdin
150
stdout
Кофе-машина
Введите деньги
Вы можете купить капучино
Вы можете купить эспрессо
Вы можете купить воду
Вы можете купить молоко