• Source
    1. /* package whatever; // don't place package name! */
    2.  
    3. import java.util.*;
    4.  
    5.  
    6. /* Name of the class has to be "Main" only if the class is public. */
    7. class Ideone
    8. {
    9. public static void main (String[] args)
    10. {
    11. System.out.println("Кофе-машина");
    12. Scanner scanner = new Scanner(System.in);
    13. System.out.print("Внесите сумму");
    14. int moneyAmount = scanner.nextInt();
    15. scanner.close();
    16. int espressoPrice = 100;
    17. int cappucinoPrice = 200;
    18. int waterPrice = 10;
    19. int milkPrice = 50;
    20.  
    21. boolean canBuySomething = false;
    22.  
    23. if(moneyAmount >= milkPrice) {
    24. System.out.println("Вы можете купить молоко");
    25. canBuySomething = true;
    26. }
    27.  
    28. if(moneyAmount >= espressoPrice) {
    29. System.out.println("Вы можете купить эспрессо");
    30. canBuySomething = true;
    31. }
    32.  
    33. if(moneyAmount >= cappucinoPrice) {
    34. System.out.println("Вы можете купить капучино");
    35. canBuySomething = true;
    36. }
    37.  
    38. if(moneyAmount >= waterPrice) {
    39. System.out.println("Вы можете купить воду");
    40. canBuySomething = true;
    41. }
    42.  
    43. if(canBuySomething == false) {
    44. System.out.println("Недостаточно средств. Учите джаву и идите работать!");
    45. }
    46. }
    47. }