Created
February 17, 2025 11:56
-
-
Save sunghyuck-cpf21b/90f727265facc57832b90f3f8e54ec78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 양성혁 | |
| import java.util.Scanner; | |
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println("[과세금액 계산 프로그램]"); | |
| Scanner sc = new Scanner(System.in); | |
| System.out.print("연소득을 입력해 주세요.:"); | |
| int income = sc.nextInt(); | |
| if (income < 0) { | |
| throw new IllegalArgumentException("올바른 금액을 입력해주세요."); | |
| } | |
| // 과세 표준, 세율, 누진공세 | |
| int[] taxBase = {0, 12, 46, 88, 150, 300, 500, 1000}; | |
| for (int i = 0; i < taxBase.length; i++) { | |
| taxBase[i] = taxBase[i] * 1000000; | |
| } | |
| int[] per = {6, 15, 24, 35, 38, 40, 42, 45}; | |
| int[] deduction = { | |
| 0, 1080000, 5220000, 14900000, 19400000, 25400000, 35400000, 65400000 | |
| }; | |
| // 소득 범위 판단 | |
| int index = 0; | |
| for (int i = 0; i < 8; i++) { | |
| if (income < taxBase[i]) { break; } | |
| index = i; | |
| } | |
| System.out.println("index = " + index); | |
| // 세금 | |
| long tax1 = 0; | |
| for (int i = 0; i < index + 1; i++) { | |
| int amount = i == index ? income - taxBase[i] : taxBase[i + 1] - taxBase[i]; | |
| System.out.println(i == index); | |
| System.out.println("amount = " + amount); | |
| System.out.println(taxBase[i+1] + "|" + taxBase[i]); | |
| long calc = (long) amount * per[i] / 100; | |
| tax1 = tax1 + calc; | |
| System.out.printf("%10d", amount); | |
| System.out.print(" * "); | |
| System.out.printf("%2d%% =", per[i]); | |
| System.out.printf("%10d", calc); | |
| System.out.println(); | |
| } | |
| // 누진공제 | |
| long tax2 = ((long) income * per[index] / 100) - deduction[index]; | |
| System.out.printf("\n%-20s %d", "[세율에 의한 세금]:", tax1); | |
| System.out.printf("\n%-20s %d", "[누진공제 계산에 의한 세금]:", tax2); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment