/
Ilshatt
/
tax
Обзор
Документация
Войти
/
Ilshatt
/
tax
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
77 строк
3 KB
Ilshatt
upload files
11 май 2025, 16:10
11 май 2025, 16:10
c098d12
Код
Авторство
О чём код?
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; while (true) { System.out.println("Выберите операцию и введите ее номер:"); System.out.println("1. Добавить новый доход:"); System.out.println("2. Добавить новый расход:"); System.out.println("3. Выбрать систему налогообложения:"); String input = scanner.nextLine(); if ("end".equals(input)) { System.out.println("Программа завершена!"); 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("Введите сумму расхода:"); String moneySpnd = scanner.nextLine(); int spend = Integer.parseInt(moneySpnd); spendings += spend; break; case 3: System.out.println("Выбрать систему налогообложения:"); int tax = taxEarningsMinusSpendings(earnings, spendings); int tax2 = taxEarningsSpendings(earnings); if (tax <= tax2) { System.out.println("Мы советуем вам УСН доходы"); System.out.println("Ваш налог составит:" + tax + "рублей"); System.out.println("Налог на другой системе:" + tax2 + "рублей"); System.out.println("Экономия:" + (tax2 - tax) + "рублей"); } else { System.out.println("Мы советуем вам УСН доходы"); System.out.println("Ваш налог составит:" + tax2 + "рублей"); System.out.println("Налог на другой системе:" + tax + "рублей"); System.out.println("Экономия:" + (tax - tax2) + "рублей"); } break; default: System.out.println("Такой операции нет"); } } } 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 taxEarningsSpendings (int earnings) { int tax2 = earnings * 6 / 100; if (tax2 >= 0) { return tax2; } else { return 0; } } }