Skip to content

Instantly share code, notes, and snippets.

@ramyo564
Created November 8, 2023 13:07
Show Gist options
  • Save ramyo564/d454826313bc42e37cb9fca9f675c450 to your computer and use it in GitHub Desktop.
Save ramyo564/d454826313bc42e37cb9fca9f675c450 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Main {
public static int taxRefund(int money){
double tax = 0;
double moneyAsDouble = (double) money;
if (money > 1000000000){
tax = moneyAsDouble * 0.45 - 65400000;
} else if (money <= 1000000000 && money > 500000000) {
tax = moneyAsDouble * 0.42 - 35400000;
} else if (money <= 500000000 && money > 300000000) {
tax = moneyAsDouble * 0.40 - 25400000;
} else if (money <= 300000000 && money > 150000000) {
tax = moneyAsDouble * 0.38 - 19400000;
} else if (money <= 150000000 && money > 88000000) {
tax = moneyAsDouble * 0.35 - 14900000;
} else if (money <= 88000000 && money > 46000000) {
tax = moneyAsDouble * 0.24 - 5220000;
} else if (money <= 46000000 && money > 12000000) {
tax = moneyAsDouble * 0.15 - 1080000;
}else {
tax = moneyAsDouble * 0.06;
}
int taxAsTaxRounded = (int) Math.round(tax);
return taxAsTaxRounded;
}
public static void main(String[] args) {
double[] taxList = {0.06, 0.15, 0.24, 0.35, 0.38, 0.40, 0.42, 0.45};
int[] taxMoney = {12000000, 34000000, 42000000, 62000000, 150000000,200000000,500000000};
Scanner scanner = new Scanner(System.in);
System.out.println("[과세금액 계산 프로그램]");
System.out.print("연소득을 입력해 주세요.:");
int money = scanner.nextInt();
double tax = 0;
int taxAsInt = 0;
int taxRate = 0;
int taxAsTax = 0;
int taxAsRefund = 0;
taxAsRefund = taxRefund(money);
if (money <= 12000000) {
tax = money * 0.06;
taxAsInt = (int)tax;
taxAsTax += taxAsInt;
System.out.printf(" %d * 6%% = %d\n",money, taxAsInt);
System.out.println();
}else{
for (int i = 0; i < taxList.length; i++) {
if(money > 12000000 && i < 7) {
tax = taxMoney[i] * taxList[i];
taxAsInt = (int) tax;
money -= taxMoney[i];
taxAsTax += taxAsInt;
taxRate = (int) (taxList[i] * 100);
System.out.printf(" %12d * %2d%% = %9d\n", taxMoney[i], taxRate, taxAsInt);
} else if (money ==0) {
break;
}else {
tax = money * taxList[i];
taxAsInt = (int)tax;
taxAsTax += taxAsInt;
taxRate = (int)(taxList[i] * 100);
System.out.printf(" %12d * %2d%% = %9d\n",money,taxRate, taxAsInt);
break;
}
}
}
System.out.printf("[세율에 의한 세금]: %d\n", taxAsTax);
System.out.printf("[누진공제 계산에 의한 의한 세금]: %d\n", taxAsRefund);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment