/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Кофе-машина");
System.out.println("Введите сумму: ");
int moneyAmount = new Scanner(System.in).nextInt();
int[] drinkPrices = {200, 100, 50, 40};
String[] drinkNames = {"капучино", "эспрессо", "вода", "молоко"};
boolean canBuyAnything = false;
int length = Math.min(drinkPrices.length, drinkNames.length);
for (int i = 0; i < length; i++) {
if (moneyAmount >= drinkPrices[i]) {
System.out.println(
"Вы можете купить " + drinkNames[i]
);
canBuyAnything = true;
}
}
if (!canBuyAnything) {
System.out.println("Недостаточно средств :( Изучайте Java и зарабатывайте много!))");
}
}
}