/
Vitalii01
/
HomeworkForTheLessonDataTypesInJavaPrimitives
Обзор
Документация
Войти
/
Vitalii01
/
HomeworkForTheLessonDataTypesInJavaPrimitives
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Program.java
72 строки
4 KB
Vitalii01
upload files
29 мар 2025, 08:47
29 мар 2025, 08:47
26653ee
Код
Авторство
О чём код?
import java.util.Scanner; import java.util.stream.StreamSupport; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Ввод данных int income = 0; // Доход int expenditure = 0; // Расход while (true) { // Работа программы - до System.out.println("\r\nВыберите операцию и введите ее номер:"); System.out.println("1. Добавить новый доход"); System.out.println("2. Добавить новый расход"); System.out.println("3. Выбрать систему налогообложения"); String input = scanner.nextLine(); if (input.equals("end")) { System.out.println("\r\nПрограмма завершена!!!"); break; } else { int operation = Integer.parseInt(input); switch (operation) { case 1: System.out.println("Введите сумму дохода:"); String cashFlow = scanner.nextLine(); int money = Integer.parseInt(cashFlow); income += money; break; case 2: System.out.println("Ведите сумму расходов:"); String moneyExpenditure = scanner.nextLine(); int expenditureResult = Integer.parseInt(moneyExpenditure); expenditure += expenditureResult; break; case 3: int theResultOfIncomeMinusExpenses = taxEarningsMinusSpendingsIncomeMinusExpenses(income, expenditure); // УСН доходы минус расходы: 135 int revenueResult = taxEarningsMinusSpendingsIncome(income); // УСН доходы: 6% от 1000 рублей = 60 рублей if (theResultOfIncomeMinusExpenses > revenueResult) { System.out.println("\nМы посоветуем вам: УСН доходы"); System.out.println("Ваш налог составит: " + revenueResult + " рублей"); System.out.println("Налог на другой системе: " + theResultOfIncomeMinusExpenses + "рублей"); System.out.println("Экономия: " + (theResultOfIncomeMinusExpenses - revenueResult) + " рублей"); } else { System.out.println("\nМы посоветуем вам: УСН доходы минус расходы:"); System.out.println("Ваш налог составит: " + theResultOfIncomeMinusExpenses + " рублей"); System.out.println("Налог на другой системе: " + revenueResult + "рублей"); System.out.println("Экономия: " + (revenueResult - theResultOfIncomeMinusExpenses) + " рублей"); } break; default: System.out.println("Такой операции нет!!!"); } } } } public static int taxEarningsMinusSpendingsIncomeMinusExpenses(int earnings, int spendings) { // // УСН доходы минус расходы: 135 int tax = (earnings - spendings) * 15 / 100; if (tax >= 0) { return tax; } else return 0; } public static int taxEarningsMinusSpendingsIncome(int earnings) { // УСН доходы: 6% от 1000 рублей = 60 рублей int tax = earnings / 100 * 6; if (tax >= 0) { return tax; } else { return 0; } } }