public class CurrencyAnalyzer { private static double last_value = -1; public static void analyze(double current) { if (last_value == -1) { last_value = current; String start_msg = "Мониторинг курса USD запущен\n" + "Текущий курс: " + current + " ₽"; TelegramNotifier.sendMessage(start_msg); System.out.println("Начальное значение USD: " + current); return; } String msg = ""; if (current > last_value) { msg = "Курс доллара вырос ↑"; } else if (current < last_value) { msg = "Курс доллара упал ↓"; } else { return; } String telegram_msg = msg + "\n" + "Было: " + last_value + " ₽\n" + "Стало: " + current + " ₽"; TelegramNotifier.sendMessage(telegram_msg); System.out.println(msg.replace("", "").replace("", "") + " (было " + last_value + ", стало " + current + ")"); last_value = current; } }