Katkat

Model an Extensible Employee Cost Calculator

AmazonSoftware Engineer · Onsite

Last updated

Model an extensible employee cost calculator combining salary, tax, benefits, and a signed location adjustment. Discuss precise money handling, explicit missing policies, canonical identifiers, versioned configuration, reproducible breakdowns, and boundary-focused tests.

Design an object model and calculation API for the total cost of an employee. Total cost has four components:

  1. Base salary from the employee record.
  2. Tax as a fixed percentage of base salary.
  3. Benefits from a lookup keyed by (level, title).
  4. A positive or negative location adjustment from a lookup keyed by location.

Define the necessary types and implement the calculation conceptually. Explain validation, money representation, missing lookup entries, configuration versioning, and tests. The goal is an extensible design, not a hard-coded chain of conditionals.

Constraints & Assumptions

  • All monetary values use one declared currency for a single calculation.
  • Tax rate and lookup tables are supplied configuration, not global constants hidden inside the employee class.
  • Level, title, and location use canonical identifiers.
  • A calculation should be reproducible after compensation rules change.

Clarifying Questions to Ask

  • Is tax truly a single fixed rate, or can it vary by employee or location?
  • Should a missing benefit or location rule fail, default to zero, or use a fallback hierarchy?
  • Are adjustments annual amounts or percentages?
  • What rounding mode and currency precision are required?

Follow-up questions

  • How would you support progressive tax brackets without changing callers?
  • How would effective-dated policy changes be applied to historical calculations?
  • What should happen if salary and adjustment inputs use different currencies?