11. The primary series of personal income tax issues

Personal Income Tax

Problem Description

Write a program to calculate personal income tax

After asked to enter the amount of revenue that can output the personal income tax payable,

Personal income tax collection methods are as follows:

Threshold of 3,500 yuan

Not more than 1500 yuan part, levy of 3%

1500-4500 yuan more than the part, the collection of 10%

Over 4500-9000 yuan part, the collection of 20%

9000-35000 yuan more than the part, the collection of 25%

More than 35000-55000 yuan part, the collection of 30%

More than 55000-80000 yuan part, the collection of 35%

More than 80,000 yuan, the collection of 45%

problem analysis

Title characteristic analysis, consider the condition of the subject structure described

c language allows users to define the structure, which corresponds to the recording of other high-level languages

The general form of a statement of the type of structure

struct structure name

Structure member list {}

algorithm design

Storing structure using a range of different rates, then used for each cycle through the range of taxation

The amount exceeds the threshold of personal income taxation in each range should pay taxes add up

Finally, we should get the personal income tax paid

#include <stdio.h>

#define TAXBASE 3500

/* !<定义结构体 */
typedef struct {
    long start;
    long end;
    double taxrate;
} TAXTABLE;

/* 定义结构体数组 */
TAXTABLE TaxTable[] = {
                        {0, 1500, 0.03},
                        {1500, 4500, 0.10},
                        {4500, 9000, 0.20},
                        {9000, 35000, 0.25},
                        {35000, 55000, 0.30},
                        {55000, 80000, 0.35},
                        {80000, 1e10, 0.45}
                      };
/* !<Caculate function */
double CaculateTax(long profit)
{
    int i;
    double tax = 0.0;
    profit -= TAXBASE;      /* !< 超过个税起征点的收入 */
    for (i = 0; i < sizeof(TaxTable)/sizeof(TAXTABLE); i++) {
        /* !<判断profit是否在当前的缴税范围内 */
        if (profit > TaxTable[i].start) {
            if (profit > TaxTable[i].end) {
                tax += (TaxTable[i].end - TaxTable[i].start)*TaxTable[i].taxrate;
            }
            else {  /* !< profit 未超过当前的缴税范围 */
                tax += (profit - TaxTable[i].start)*TaxTable[i].taxrate;
            }
            profit -= TaxTable[i].end;
            printf("征税范围: %6ld-%6ld 该范围内缴税金额: %6.2f 超出该范围的金额:%6ld\n",
                    TaxTable[i].start,TaxTable[i].end,tax,(profit)>0 ? profit : 0);
        }
    }
    return tax;
}

int main(void)
{
    long profit;
    double tax;
    printf("请输入个人收入金额:");
    scanf("%ld", &profit);
    tax = CaculateTax(profit);
    printf("您的个人所得税为: %12.2f\n",tax);
}


/* !< output */ 
    请输入个人收入金额:9876
    征税范围:      0-  1500 该范围内缴税金额:  45.00 超出该范围的金额:  4876
    征税范围:   1500-  4500 该范围内缴税金额: 345.00 超出该范围的金额:   376
    您的个人所得税为:       345.00

    Process returned 0 (0x0)   execution time : 2.772 s
    Press any key to continue.

Guess you like

Origin www.cnblogs.com/xuzhaoping/p/11484560.html