/
ZIKFOX
/
JOB4-1
Обзор
Документация
Войти
/
ZIKFOX
/
JOB4-1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
91 строка
3 KB
ZIKFOX
JOB4-1
01 дек 2025, 13:19
01 дек 2025, 13:19
283432c
Код
Авторство
О чём код?
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 taxEarningsSpendings(int earnings) { int tax2 = earnings * 6 / 100; if (tax2 >= 0) { return tax2; } else { return 0; } } public static void menu() { System.out.println("�������� �������� � ������� � �����:"); System.out.println("1. �������� ����� �����"); System.out.println("2. �������� ����� ������"); System.out.println("3. ������� ������� ���������������"); System.out.println("��� ���������� ���������, ������� 'end'"); } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int earnings = 0; int spendings = 0; while (true) { menu(); String input = scanner.nextLine().trim(); if ("end".equalsIgnoreCase(input)) { break; } try { int operation = Integer.parseInt(input); switch (operation) { case 1: System.out.print("������� ����� ������: "); int income = Integer.parseInt(scanner.nextLine()); earnings += income; break; case 2: System.out.print("������� ����� �������: "); int expense = Integer.parseInt(scanner.nextLine()); spendings += expense; break; case 3: 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("����� �������� ���."); } } catch (NumberFormatException e) { System.out.println("������������ ����. ��������� �������."); System.out.println("��������� ���������!"); } } } }