Skip to content

Instantly share code, notes, and snippets.

@bongbongbon
Created January 15, 2024 12:08
Show Gist options
  • Save bongbongbon/45822118321988a044812d3e2897e469 to your computer and use it in GitHub Desktop.
Save bongbongbon/45822118321988a044812d3e2897e469 to your computer and use it in GitHub Desktop.
JavaStudy08.java
import java.util.Scanner;
public class JavaStudy08 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("연소득을 입력하세요 (만원 단위): ");
int income = scanner.nextInt();
int[] incomeLevels = {1200, 4600, 8800, 15000, 30000};
double[] taxRates = {0.06, 0.15, 0.24, 0.35, 0.38};
int[] basicTaxStandards = {0, 72, 582, 1590, 3760};
double totalTax = 0.0;
for (int i = 0; i < incomeLevels.length; i++) {
if (income <= incomeLevels[i]) {
totalTax += (income - basicTaxStandards[i]) * taxRates[i];
break;
} else {
totalTax += (incomeLevels[i] - basicTaxStandards[i]) * taxRates[i];
}
}
System.out.println("연소득: " + income + "만원");
System.out.println("과세금액: " + totalTax + "만원");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment