/
ilichevPavel
/
DZ_Primitives
Обзор
Документация
Войти
/
ilichevPavel
/
DZ_Primitives
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
70 строк
3 KB
ilichevPavel
upload files
02 ноя 2025, 15:15
02 ноя 2025, 15:15
a4f505f
Код
Авторство
О чём код?
import java.util.Scanner; public class Main { public static int taxEarningsMinusSpendings(int earnings, int spendings) { int tax = (earnings - spendings) * 15 / 100; if (tax >= 0) { return tax; } else { return 0; } } public static int taxEarnings(int earnings) { int tax = earnings * 6 / 100; return tax; } public static void main(String[] args) { int earnings = 0; // доходы int spendings = 0; // расходы Scanner scanner = new Scanner(System.in); while (true) { System.out.println("1. Добавить новый доход"); System.out.println("2. Добавить новый расход"); System.out.println("3. Выбрать систему налогообложения"); String input = scanner.nextLine(); if ("end".equals(input)) { break; } int operation = Integer.parseInt(input); switch (operation) { case 1: System.out.println("Введите сумму дохода:"); String moneyStr = scanner.nextLine(); int money = Integer.parseInt(moneyStr); earnings += money; break;// действия при выборе первой операции case 2: System.out.println("Введите сумму расхода:"); moneyStr = scanner.nextLine(); money = Integer.parseInt(moneyStr); spendings += money; break;// действия при выборе второй операции case 3: int taxEarnings = taxEarnings(earnings); int taxEarningsMinusSpendings = taxEarningsMinusSpendings(earnings, spendings); if (taxEarningsMinusSpendings > taxEarnings) { System.out.println("Мы советуем вам УСН доходы"); System.out.println("Ваш налог составит: " + taxEarnings + " рублей"); System.out.println("Налог на другой системе: " + taxEarningsMinusSpendings + " рублей"); System.out.println("Экономия: " + (taxEarningsMinusSpendings - taxEarnings) + " рублей"); }else if (taxEarningsMinusSpendings == taxEarnings) { System.out.println("Можете выбрать любую систему налогообложения"); } else { System.out.println("Мы советуем вам УСН доходы минус расходы"); System.out.println("Ваш налог составит: " + taxEarningsMinusSpendings + " рублей"); System.out.println("Налог на другой системе: " + taxEarnings + " рублей" ); System.out.println("Экономия: " + (taxEarnings-taxEarningsMinusSpendings) + " рублей"); } break; default: System.out.println("Такой операции нет"); } } } }