#include
<stdio.h>
#define LIMIT1 10000000.0
#define LIMIT2 20000000.0
#define LIMIT3 50000000.0
#define
TAX_RATE_1 0.0
#define
TAX_RATE_2 0.20
#define
TAX_RATE_3 0.30
#define
TAX_RATE_4 0.40
#define
LABOR_RATE 0.50
#define
FAMILY_DEDUCTION_PER_ONE 1000000.0
#define
DEDUCTION_LIMIT_FOR_MEDICAL_CARE 3000000.0
#define
DEDUCTION_LIMIT_FOR_INSURANCE 2000000.0
main()
{
int normal_condition; /*
정상상태 여부 */
int flag;
int is_labor; /*
근로 소득 여부 */
int nu_of_family; /*
가족 수 */
double total_income; /*
총수입액 */
double total_medical_cost; /*
의료비 총액 */
double total_insurance_cost; /*
보험료 총액 */
double deduction_for_labor_income; /* 근로공제액 */
double deduction_for_family; /*
가족공제액 */
double deduction_for_medical_care; /* 의료공제액 */
double deduction_for_insurance; /* 보험공제액 */
double total_deduction; /*
총공제액 */
double income_for_tax; /*
과세대상총액 */
double total_tax; /*
세금총액 */
/* 프로그램
안내 */
printf("세금
계산 프로그램입니다 \n");
/* 총 급여액,
근로소득 여부, 가족수, 의료비용 총액, 보험 총액 입력 */
normal_condition
= 1;
printf("총금여액을
넣어주세요 : ");
flag
= scanf("%lf", &total_income);
while
((flag == 1) && (total_income < 0)) {
printf("총금여액은
0보다 커야합니다. 다시 입력 : ");
flag
= scanf("%lf", &total_income);
}
if
(flag != 1) {
normal_condition
= 0;
}
if
(normal_condition) {
printf("근로소득이
아니면 0, 근로소득이면 0이 아닌 다른 번호를 입력하세요 : ");
flag
= scanf("%d", &is_labor);
if
(flag != 1) {
normal_condition
= 0;
}
}
if
(normal_condition) {
printf("가족수를
넣어주세요 : ");
flag
= scanf("%d", &nu_of_family);
while
((flag == 1) && (nu_of_family < 1)) {
printf("가족
수는 1 이상이어야 합니다. 다시 입력 : ");
flag
= scanf("%d", &nu_of_family);
}
if
(flag != 1) {
normal_condition
= 0;
}
}
if (normal_condition)
{
printf("의료비
총액을 넣어주세요 : ");
flag
= scanf("%lf", &total_medical_cost);
while
((flag == 1) && (total_medical_cost < 0.0)) {
printf("의료비
총액은 0 이상이어야 합니다. 다시 입력 : ");
flag
= scanf("%lf", &total_medical_cost);
}
if
(flag != 1) {
normal_condition
= 0;
}
}
if
(normal_condition) {
printf("보험료
총액을 넣어주세요 : ");
flag
= scanf("%lf", &total_insurance_cost);
while
((flag == 1) && (total_medical_cost < 0.0)) {
printf("보험료
총액은 0 이상이어야 합니다. 다시 입력 : ");
flag
= scanf("%lf", &total_insurance_cost);
}
if
(flag != 1) {
normal_condition
= 0;
}
}
if
(normal_condition) { /*
정상적으로 입력을 모두 받았을 때 */
/*
공제액 초기화 */
deduction_for_labor_income
= 0.0;
deduction_for_family
= 0.0;
deduction_for_medical_care
= 0.0;
deduction_for_insurance
= 0.0;
/*
공제액 계산 */
if
(is_labor) {
deduction_for_labor_income
= total_income * LABOR_RATE;
}
deduction_for_family
= nu_of_family * FAMILY_DEDUCTION_PER_ONE;
if
(total_medical_cost <= DEDUCTION_LIMIT_FOR_MEDICAL_CARE) {
deduction_for_medical_care
= total_medical_cost;
}
else
{
deduction_for_medical_care
= DEDUCTION_LIMIT_FOR_MEDICAL_CARE;
}
if
(total_insurance_cost <= DEDUCTION_LIMIT_FOR_INSURANCE) {
deduction_for_insurance
= total_insurance_cost;
}
else
{
deduction_for_insurance
= DEDUCTION_LIMIT_FOR_INSURANCE;
}
total_deduction
= deduction_for_labor_income
+
deduction_for_family
+
deduction_for_medical_care
+
deduction_for_insurance;
/*
과세대상 총액 계산 */
income_for_tax
= total_income - total_deduction;
if
(income_for_tax < 0.0) {
income_for_tax
= 0.0;
}
/*
세금 계산 */
if
(income_for_tax < LIMIT1) {
total_tax
= income_for_tax * TAX_RATE_1;
}
else
if (income_for_tax < LIMIT2) {
total_tax
= LIMIT1 * TAX_RATE_1
+
(income_for_tax - LIMIT1) * TAX_RATE_2;
}
else
if (income_for_tax < LIMIT3) {
total_tax
= LIMIT1 * TAX_RATE_1
+
(LIMIT2 - LIMIT1) * TAX_RATE_2
+
(income_for_tax - LIMIT2) * TAX_RATE_3;
}
else
{
total_tax
= LIMIT1 * TAX_RATE_1
+
(LIMIT2 - LIMIT1) * TAX_RATE_2
+
(LIMIT3 - LIMIT2) * TAX_RATE_3
+
(income_for_tax - LIMIT3) * TAX_RATE_4;
}
/*
결과 출력 */
printf("%10.0f
%10.0f %10.0f\n", total_income, income_for_tax, total_tax);
}
else
{ /* 입력을 제대로 못받은 오류 상황 */
printf("잘못된
입력으로 계산이 불가능합니다.\n");
}
}