[UVA] 12342 - Tax Calculator
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 |
Case 1: 2000 |
#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;
}