From dab17ba977b3d303bfd42401f9b485c4a8d02b02 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: Fri, 3 Jul 2026 12:02:50 +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 | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/src/TaskDemo.java b/src/TaskDemo.java index bfae9a2..0f7a0db 100644 --- a/src/TaskDemo.java +++ b/src/TaskDemo.java @@ -1,44 +1,22 @@ import java.util.Arrays; +import java.util.SplittableRandom; public class TaskDemo { public static void main(String[] args) { - - int[] time = {20, 51, 55, 66, 45, 54}; - System.out.println("Общее количество минут: " + calculateTotalMinutes(time)); - System.out.println("Среднее время просмотра: " + calculateTotalMinutes(time) / time.length); - - System.out.println("Количество дней больше 50 минут :" + countLongSessions(time) + "дней"); - System.out.println("Ваш статус: " + getUserStatus(countLongSessions(time))); + String name = " евгений "; + System.out.println(formatUserName(name)); } - public static int calculateTotalMinutes(int[] time) { - int days = 0; + public static String formatUserName(String name) { + String cleanName = name.trim(); + String firstLetter = cleanName.substring(0, 1).toUpperCase(); + String restOfName = cleanName.substring(1).toLowerCase(); - for (int i = 0; i < time.length; i++) { - days += time[i]; - } - return days; + + return firstLetter + restOfName; } +} - public static int countLongSessions(int[] time) { - int count = 0; - for (int i = 0; i < time.length; i++) { - if (time[i] > 50) { - count++; - } - } - return count; - } - public static Status getUserStatus(int count) { - switch (count) { - case 0, 1, 2 -> {return Status.LOW;} - case 3, 4, 5 -> {return Status.MEDIUM;} - default -> {return Status.HIGH;} - } - } - - -} \ No newline at end of file