/
advo_kitty
/
22.11.2025_Task5
Обзор
Документация
Войти
/
advo_kitty
/
22.11.2025_Task5
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
75 строк
3 KB
advo_kitty
upload files
21 ноя 2025, 13:34
21 ноя 2025, 13:34
602bcfd
Код
Авторство
О чём код?
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or // click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int earnings = 0; int spendings = 0; boolean isContinue = true; while (isContinue) { showOptions(); String option = scanner.nextLine(); switch (option) { case "1": System.out.println("Введите сумму доходов: "); earnings += Integer.parseInt(scanner.nextLine()); break; case "2": System.out.println("Введите сумму расходов: "); spendings += Integer.parseInt(scanner.nextLine()); break; case "3": chooseTaxSystem(earnings, spendings); break; case "end": isContinue = false; break; default: System.out.println("Введено недопустимое значение"); } } System.out.println("Программа завершена"); } public static void chooseTaxSystem(int earnings, int spendings) { int simpleTax = calcTax6(earnings); int complexTax = calcTax15(earnings, spendings); int minTax = Math.min(simpleTax, complexTax); int maxTax = Math.max(simpleTax, complexTax); String taxSystem = simpleTax < complexTax ? "УСН доходы" : "УСН доходы - расходы"; if (minTax == maxTax) { System.out.println("Можете выбрать любую систему налогов!"); System.out.printf("Ваш налог составит: %d рублей\n", minTax); } else { System.out.printf("Мы советуем вам %s\n", taxSystem); System.out.printf("Ваш налог составит: %d рублей\n", minTax); System.out.printf("Налог на другой системе: %d рублей\n", maxTax); System.out.printf("Экономия: %d рублей\n", maxTax - minTax); } } public static int calcTax6 ( int earnings){ return 6 * earnings / 100; } public static int calcTax15 ( int earnings, int spendings){ int tax = 15 * (earnings - spendings) / 100; if (tax < 0) { return 0; } else { return tax; } } public static void showOptions () { System.out.println("Выберите операцию и введите её номер: "); System.out.println("1. Добавить новый доход: "); System.out.println("2. Добавить новый расход: "); System.out.println("3. Выбрать систему налогообложения: "); } }