Model progressive income-tax brackets with BigDecimal and filing-year policies

Quick Overview

Build a progressive tax calculator with TaxBuckets and BigDecimal arithmetic. Separate bracket calculations from filing-year, filing-status, and W2 income policies, and explain decimal precision and boundary behavior.

Model progressive income-tax brackets with BigDecimal and filing-year policies

Company: Gusto

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Implement an object-oriented progressive income-tax calculator. Represent tax brackets with a `TaxBuckets` class, and use Java `BigDecimal` for every monetary amount, bracket boundary, and tax rate. Given annual income and a selected bracket table, calculate the tax contributed by each bracket and sum the results. Extend the design to support different filing statuses and tax years through a `FilingStatus` enum and a `TaxFilingYear` interface. A year-specific implementation should accept a filing status and W2 data and return the calculated tax. The exercise uses a supplied tax table. It does not require memorizing current tax rules. ### Constraints and Clarifications Use caller-supplied bracket data for the selected year and status. No numerical IRS table is supplied here. Any example table must be labeled hypothetical. Separate the calculation over taxable income from the policy that converts W2 wages into taxable income. ### Clarifying Questions - Does the initial income argument already represent taxable income, or must deductions be applied to W2 wages? - Which W2 field is the wage input, and how should multiple W2 forms be combined? - What rounding rule and output scale apply, and at what stage should rounding occur? - What should happen if a requested year or filing status has no configured table? ### Part 1: Calculate bracket contributions Implement `TaxBuckets` and the bracket iteration. Show the result at a bracket boundary and above it using hypothetical numbers. ```hint Tax one interval at a time Track the portion of income that lies inside a bracket before applying its rate. ``` #### What This Part Should Cover - Ordered bracket boundaries and progressive marginal taxation - `BigDecimal` construction, comparison, and rounding - Validation, a worked calculation, and cost analysis ### Part 2: Add filing-year and status policies Define `FilingStatus` and `TaxFilingYear`, and show how a year implementation chooses its bracket table and processes W2 data. Keep policy data separate from the bracket arithmetic. ```hint Identify what changes each year Distinguish the arithmetic that stays the same from the table and income policies that depend on the selected year and status. ``` #### What This Part Should Cover - Year/status table selection and the W2 input contract - Separation of taxable-income policy, tax computation, and presentation rounding - Missing-configuration behavior and tests across bracket boundaries ### What a Strong Answer Covers - Complete decimal-safe bracket arithmetic - Extensible year/status handling without embedding one year's thresholds in the algorithm - Explicit limits on what the calculator includes, such as deductions, credits, and withholding ### Follow-up Questions - How would you return a bracket-by-bracket explanation alongside the total? - How would you prevent a missing year's table from silently falling back to another year? - If withholding is added, how would you distinguish tax liability from a refund or balance due?

Overview: Build a progressive tax calculator with TaxBuckets and BigDecimal arithmetic. Separate bracket calculations from filing-year, filing-status, and W2 income policies, and explain decimal precision and boundary behavior.

Read the full Gusto Software Engineer interview experience this question came from

Gusto logo
Gusto
Dec 2, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Implement an object-oriented progressive income-tax calculator. Represent tax brackets with a TaxBuckets class, and use Java BigDecimal for every monetary amount, bracket boundary, and tax rate. Given annual income and a selected bracket table, calculate the tax contributed by each bracket and sum the results.

Extend the design to support different filing statuses and tax years through a FilingStatus enum and a TaxFilingYear interface. A year-specific implementation should accept a filing status and W2 data and return the calculated tax. The exercise uses a supplied tax table. It does not require memorizing current tax rules.

Constraints and Clarifications

Use caller-supplied bracket data for the selected year and status. No numerical IRS table is supplied here. Any example table must be labeled hypothetical. Separate the calculation over taxable income from the policy that converts W2 wages into taxable income.

Clarifying Questions Guidance

  • Does the initial income argument already represent taxable income, or must deductions be applied to W2 wages?
  • Which W2 field is the wage input, and how should multiple W2 forms be combined?
  • What rounding rule and output scale apply, and at what stage should rounding occur?
  • What should happen if a requested year or filing status has no configured table?

Part 1: Calculate bracket contributions

Implement TaxBuckets and the bracket iteration. Show the result at a bracket boundary and above it using hypothetical numbers.

What This Part Should Cover Guidance

  • Ordered bracket boundaries and progressive marginal taxation
  • BigDecimal construction, comparison, and rounding
  • Validation, a worked calculation, and cost analysis

Part 2: Add filing-year and status policies

Define FilingStatus and TaxFilingYear, and show how a year implementation chooses its bracket table and processes W2 data. Keep policy data separate from the bracket arithmetic.

What This Part Should Cover Guidance

  • Year/status table selection and the W2 input contract
  • Separation of taxable-income policy, tax computation, and presentation rounding
  • Missing-configuration behavior and tests across bracket boundaries

What a Strong Answer Covers Guidance

  • Complete decimal-safe bracket arithmetic
  • Extensible year/status handling without embedding one year's thresholds in the algorithm
  • Explicit limits on what the calculator includes, such as deductions, credits, and withholding

Follow-up Questions Guidance

  • How would you return a bracket-by-bracket explanation alongside the total?
  • How would you prevent a missing year's table from silently falling back to another year?
  • If withholding is added, how would you distinguish tax liability from a refund or balance due?