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)

  1. The First $10,000: 0% Tax (Completely free!)
  2. The Next $20,000 (Up to $30,000): 10% Tax.
  3. 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

Inputincome = 35000
Output3000

Explanation: Calculated across all three slabs.

02EXAMPLE 2

Inputincome = 5000
Output0

Explanation: Income is entirely in the 0% bracket.

Constraints

  • Income is a non-negative integer.
  • Return the final tax amount as a number.
Control FlowMathLogic
JavaScript
Loading...
4 Hidden

Input Arguments

income35000

Expected Output

3000

Click RUN to test your solution