/
Vickie
/
hw3
Обзор
Документация
Войти
/
Vickie
/
hw3
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
65 строк
3 KB
Vickie
Create: Main.java
15 июн 2026, 11:54
Верифицирован
15 июн 2026, 11:54
3e25dcf
Код
Авторство
О чём код?
import java.util.Scanner; public class Main { public static int taxSix(int earnings) { int tax = earnings / 100 * 6; System.out.println("Налог доходы: " + tax); return (tax); } public static int taxMinus(int earnings, int spendings) { int tax = (earnings - spendings) / 100 * 15; System.out.println("Налог доходы минус расходы: " + tax); if (tax >= 0) { return (tax); } else { return 0; } } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int earnings = 0; int spendings = 0; while (true) { System.out.println("Выберите операцию и введите её номер:\n" + "1. Добавить новый доход\n" + "2. Добавить новый расход\n" + "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 spendStr = scanner.nextLine(); int spend = Integer.parseInt(spendStr); spendings += spend; break; case 3: int feeSix = taxSix(earnings); int feeMinus = taxMinus(earnings, spendings); int dif = feeSix - feeMinus; if (dif > 0) { System.out.println("Мы советуем вам УСН доходы минус расходы\n" + "Ваш налог составит: " + feeMinus + " рублей\n" + "Налог на другой системе: " + feeSix + " рублей\n" + "Экономия: " + dif + " рублей\n"); } else if (dif < 0) { System.out.println("Мы советуем вам УСН доходы\n" + "Ваш налог составит: " + feeSix + " рублей\n" + "Налог на другой системе: " + feeMinus + " рублей\n" + "Экономия: " + Math.abs(dif) + " рублей\n"); } else { System.out.println("Можете выбрать любую систему налогообложения"); } ; } } } }