From 09e6ffad2954e4225ede8df4751da3890a4ff0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9?= Date: Mon, 29 Jun 2026 18:43:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=BA=D1=82=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TaskDemo.java | 49 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/TaskDemo.java b/src/TaskDemo.java index 79373dd..18d398e 100644 --- a/src/TaskDemo.java +++ b/src/TaskDemo.java @@ -1,27 +1,46 @@ +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeParseException; import java.util.Arrays; +import java.util.Scanner; + public class TaskDemo { + enum Status {Scheduled, Active, Overdue} + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + System.out.println(" Введите дату: "); + String dateText = input.nextLine(); - int[] yearUser = new int[]{2010, 1995, 2008, 2024, 2015, 1990}; - System.out.println("Совершеннолетних: " + yearUserCount(yearUser)); + System.out.println(checkDate(dateText)); } - public static int yearUserCount(int[] yearUser) { - int currentUser = 2026; - int count = 0; + public static String checkDate(String date) { + try { + LocalDate inputDate = LocalDate.parse(date); + LocalDate today = LocalDate.now(); + Status currentStatus; - for (int i = 0; i < yearUser.length; i++) { - int age = currentUser - yearUser[i]; - - if (age >= 18) { - count++; + if (inputDate.isBefore(today)) { + currentStatus = Status.Overdue; + } else if (inputDate.isEqual(today)) { + currentStatus = Status.Active; + } else { + currentStatus = Status.Scheduled; } - - - } - return count; - + switch (currentStatus) { + case Overdue: + return "Статус: Просрочено"; + case Active: + return "Статус: Активно сегодня"; + case Scheduled: + return "Статус: Запланированно"; + default: + return "Статус: Неизвестен"; + } + } catch (DateTimeParseException e ) {return "Ошибка: неверный формат ввода даты";} } + } \ No newline at end of file