24h購物| | PChome| 登入
2011-12-03 17:38:24| 人氣789| 回應0 | 上一篇 | 下一篇

[UVA] 12342 - Tax Calculator

推薦 0 收藏 0 轉貼0 訂閱站台

H

Tax Calculator

Input: Standard Input

Output: Standard Output

 

People of a certain country have a little interest in paying tax. This is not the case that they do not love the country or they do not want to obey the law, but the problem is the complex calculations for payable tax. Most of the people do not understand the rule and some lawyers take high charges to help(?) them. So, most of the people just avoid paying tax. Realizing this, the Government decided to automate the taxpaying system and appointed you to program a tax calculator that takes a person’s yearly income as input and calculate the payable tax for him. Here is the rule for calculate payable tax for an individual:

1.      The first 180,000/- of income is tax free.

2.      Next 300,000/- will have 10% tax.

3.      Next 400,000/- will have 15% tax.

4.      Next 300,000/- will have 20% tax.

5.      The rest will have 25% tax.

6.      The minimum payable tax will be 2,000/-. That is if anyone’s tax is below 2,000/- (but of course greater than zero) he must pay 2,000/-

7.      The payable tax must be an integer. If the calculated tax is a floating point then it must be replaced by the smallest integer greater than the payable tax.

 

Input

The first line of input will contain an integer T (T 5000) which denotes the number of test cases. Each of the following T lines contains an integer k (1 k ≤ 109).

 

Output

For each line of input output the case number and an integer which is the payable tax for the given income.

 

Sample Input                               Output for Sample Input

3
180001
12345
615000

Case 1: 2000
Case 2: 0
Case 3: 50250






#include<stdio.h>
#include<math.h>
int main() {
    int T, C = 0, k;
    scanf("%d", &T);
    while(T--) {
        scanf("%d", &k);
        printf("Case %d: ", ++C);
        double tex = 0;
        if(k > 180000) {
            k -= 180000;
            if(k > 0) {
                tex += (k >= 300000 ? 300000 : k)*0.1;
                k -= 300000;
                if(k > 0) {
                    tex += (k >= 400000 ? 400000 : k)*0.15;
                    k -= 400000;
                    if(k > 0) {
                        tex += (k >= 300000 ? 300000 : k)*0.2;
                        k -= 300000;
                        if(k > 0)
                            tex += k*0.25;
                    }
                }
            }
            if(tex < 2000)    puts("2000");
            else    printf("%d\n", (int)ceil(tex));
        } else
            puts("0");
    }
    return 0;
}

台長: Morris
人氣(789) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA] 1225 - Digit Counting
此分類上一篇:[UVA] 12289 - One-Two-Three

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文