Практика
This commit is contained in:
+10
-32
@@ -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;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user