PAT Branching Structure-101 Thoughts

Source: Internet
Author: User

Suppose the individual income tax is: tax rate * (Salary-1600). Please write a program to calculate the income tax payable, where the tax rate is defined as:

    • When wages do not exceed 1600, the tax rate is 0;
    • When the wage is in the interval (1600, 2500), the tax rate is 5%;
    • When the wage is in the interval (2500, 3500), the tax rate is 10%;
    • When the wage is in the interval (3500, 4500), the tax rate is 15%;
    • When wages exceed 4500, the tax rate is 20%.

      Input format:

      The input gives a non-negative wage in a row.

      Output format:

      Export personal income tax on one line, accurate to 2 digits after the decimal point.

      Input Sample 1:
      1600
      Output Example 1:
      0.00
      Input Sample 2:
      1601
      Output Example 2:
      0.05
      Input Sample 3:
      3000
      Output Example 3:
      140.00
      Input Sample 4:
      4000
      Output Example 4:
      360.00
      Input Sample 5:
      5000
      Output Example 5:
      680.00

The above are the requirements of the topic, the following is the code I wrote

1#include <stdio.h>2 intMain () {3         floatpayroll,tex_rate,sum;4scanf"%f",&Payroll);5 6         if(payroll<= the)7Tex_rate=0;8         Else if(payroll<=2500)9Tex_rate=0.05;Ten         Else if(payroll<=3500) OneTex_rate=0.1; A         Else if(payroll<=4500) -Tex_rate=0.15; -         Else theTex_rate=0.2; - //sum= (Payroll-1600) *tex_rate; -printf"%.2f\n", (payroll- the)*tex_rate); -         return 0; +}

However, instead of passing, the following error message appears:

Show my answer is wrong, I follow the requirements of the topic in the local test, the results are correct. And, I see a similar answer on CSDN's blog, so the reference http://blog.csdn.net/nirvana_wzj/article/details/38677713 is very similar to my idea, Just once every decision to do a output, so I used his code to try, incredibly passed, I am very confused, I hope to be able to explain the problem in the future.

PAT Branching Structure-101 Thoughts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.