/
weazweazweaz
/
ReworkPrimitives
Обзор
Документация
Войти
/
weazweazweaz
/
ReworkPrimitives
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
96 строк
3 KB
weazweazweaz
upload files
30 окт 2025, 10:19
30 окт 2025, 10:19
4d6666b
Код
Авторство
О чём код?
import java.util.Scanner; class Main { public static Scanner sc = new Scanner(System.in); public static int earnings = 0; public static int spendings = 0; public static void main(String[] args) { runApplication(); } public static void runApplication() { while (true) { showMenu(); String input = sc.nextLine(); if (input.equals("end")) { break; } int operation = Integer.parseInt(input); userChoice(operation); } } public static void showMenu() { System.out.println(""" Выберите операцию и введите её номер: 1. Добавить новый доход 2. Добавить новый расход 3. Выбрать систему налогообложения """); } public static void userChoice(int operation) { switch (operation) { case 1: { System.out.println("Введите сумму дохода: "); int money = getMoney(); earnings += money; break; } case 2: { System.out.println("Введите сумму расхода: "); int money = getMoney(); spendings += money; break; } case 3: { int taxIncome = calculateTaxIncome(); int taxIncomeMinusSpending = calculateTaxIncomeMinusSpendings(); compareTax(taxIncome, taxIncomeMinusSpending); } } } public static int calculateTaxIncome() { return earnings * 6 / 100; } public static int calculateTaxIncomeMinusSpendings() { int tax = (earnings - spendings) * 15 / 100; if (tax >= 0) { return tax; } else { return 0; } } public static void compareTax(int taxIncome, int taxIncomeMinusSpending) { if (taxIncome < taxIncomeMinusSpending) { int economy = taxIncomeMinusSpending - taxIncome; System.out.println("Мы советуем вам выбрать УСН доходы"); System.out.println("Ваш налог составит: " + taxIncome); System.out.println("Налог на другой системе: " + taxIncomeMinusSpending); System.out.println("Экономия: " + economy); } else if (taxIncomeMinusSpending < taxIncome) { int economy = taxIncome - taxIncomeMinusSpending; System.out.println("Мы советуем вам выбрать УСН доходы минус расходы"); System.out.println("Ваш налог составит: " + taxIncomeMinusSpending); System.out.println("Налог на другой системе: " + taxIncome); System.out.println("Экономия: " + economy); } else { System.out.println("Можете выбрать любую систему налогообложения"); System.out.println("Налоги на обеих системах равны: " + taxIncome); } } public static int getMoney() { String moneyStr = sc.nextLine(); return Integer.parseInt(moneyStr); } }