#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");

 

        }

}