/
Shcod
/
java-hw-cycles
Обзор
Документация
Войти
/
Shcod
/
java-hw-cycles
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/Main.java
38 строк
1 KB
Shcod
first commit
26 июл 2026, 08:42
26 июл 2026, 08:42
d6500c9
Код
Авторство
О чём код?
import java.util.Scanner; public class Main { private static final int DAYS_IN_LEAP_YEAR = 366; private static final int DAYS_IN_COMMON_YEAR = 365; private static int calculateDays(int year) { if (year % 400 == 0) { return DAYS_IN_LEAP_YEAR; } else if (year % 100 == 0) { return DAYS_IN_COMMON_YEAR; } else if (year % 4 == 0) { return DAYS_IN_LEAP_YEAR; } return DAYS_IN_COMMON_YEAR; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int count = 0; while (true) { System.out.println("Введите год:"); int year = scanner.nextInt(); System.out.println("Введите количество дней:"); int days = scanner.nextInt(); int correctDays = calculateDays(year); if (correctDays != days) { System.out.printf("Неправильно! В этом году %d дней!\n", correctDays); break; } else { count++; } } System.out.println("Набрано очков: " + count); scanner.close(); } }