The Royal Taxation
HardAcc. 78.5%
+40 XP 20
Paying the Crown
In a progressive tax system, you don't pay a flat fee on your total income. Instead, different portions (slabs) of your money are taxed at different rates.
The Slabs (Tax Brackets)
- The First $10,000: 0% Tax (Completely free!)
- The Next $20,000 (Up to $30,000): 10% Tax.
- The Remainder (Anything above $30,000): 20% Tax.
Example Calculation (Income: $35,000)
- Slab 1 ($0 - $10,000): $0 tax.
- Slab 2 ($10,001 - $30,000): 10% of $20,000 = $2,000 tax.
- Slab 3 ($30,001 - $35,000): 20% of $5,000 = $1,000 tax.
- Total Tax: $3,000.
Your Task
Write a function that receives income and returns the total tax as a number.
01EXAMPLE 1
Input
income = 35000Output
3000Explanation: Calculated across all three slabs.
02EXAMPLE 2
Input
income = 5000Output
0Explanation: Income is entirely in the 0% bracket.
Constraints
- Income is a non-negative integer.
- Return the final tax amount as a number.
Control FlowMathLogic
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
income35000
Expected Output
3000
Click RUN to test your solution