All challenges
Free Guided

Compound Interest Calculator

Data Science · Beginner · 50 points · about 90 min · due 20 Nov 2026

Compound interest allows an investment to grow by earning interest on both its original principal and previously accumulated interest. The final value depends on the principal, interest rate, compounding frequency, and investment duration.

In this challenge, you will build a compound interest calculator that determines the future value of an investment and the total interest earned over a specified period. The calculator must support different compounding frequencies and present the results clearly.

You will use supplied examples to verify the calculations and demonstrate how changes in interest rates, investment periods, and compounding frequency affect investment growth.

The challenge focuses on mathematical accuracy, reliable input handling, and clear presentation of financial results.

Start here · about 90 min
  • Learn the difference between principal, interest rate, compounding frequency, and investment duration.
  • Review the standard compound interest formula.
  • Work through a simple example using annual compounding.
  • Repeat the calculation using monthly or quarterly compounding.
  • Prepare test cases before building the final calculator.

Stuck? Open a hint. Try the first one before the next.

Hint 1

Convert the annual nominal interest rate into a periodic interest rate before calculating.

Hint 2

Multiply the number of years by the number of compounding periods per year to determine the total periods.

Hint 3

The future value includes the original principal; the interest earned does not.

Hint 4

A zero interest rate should produce a future value equal to the original principal.

Hint 5

Avoid rounding intermediate values before the final result is calculated.

What you'll build

Develop a functional compound interest calculator that accepts an initial principal, an annual nominal interest rate, a compounding frequency, and an investment duration, then calculates the future investment value and total interest earned.

Your checklist

  • Accept the initial principal, annual nominal interest rate, investment duration, and compounding frequency.
  • Support the compounding frequencies specified in the challenge, including annual, semi-annual, quarterly, and monthly compounding.
  • Use the standard compound interest formula for a lump-sum investment: future value equals principal multiplied by one plus the periodic interest rate, raised to the total number of compounding periods.
  • Calculate the total interest earned by subtracting the initial principal from the future value.
  • Display the principal, annual interest rate, compounding frequency, investment duration, future value, and total interest earned.
  • Validate inputs, including negative principal amounts, invalid rates, zero or negative investment durations, and unsupported compounding frequencies. Handle zero interest rates correctly.
  • Allow the investment duration and compounding frequency to be handled consistently according to the stated assumptions.
  • Round displayed monetary values to two decimal places without unnecessarily rounding intermediate calculations.
  • Include at least five test cases, including zero interest, a positive interest rate, different compounding frequencies, and invalid inputs.
  • Provide a brief explanation of the formula, the assumptions, and the difference between the future value and the interest earned.
  • Use the nominal annual interest rate and the specified compounding frequency. Assume a fixed rate throughout the investment period, no additional deposits or withdrawals, and no taxes or fees unless the challenge instructions explicitly state otherwise.

Skills you'll practise

Financial mathematics, Formula implementation, Numerical accuracy, Input validation and error handling, Testing and debugging, Technical documentation

How it's assessed

A strong submission must demonstrate all of the following:

Mathematical accuracy — 35%: Correctly applies the compound interest formula and calculates future value and total interest earned.

Compounding frequency and duration — 20%: Correctly determines the periodic rate and total number of compounding periods.

Input validation and boundary cases — 15%: Handles zero interest, invalid values, and unsupported frequencies appropriately.

Testing — 15%: Includes at least five test cases with expected and actual results.

Output clarity — 10%: Presents all financial inputs and results clearly, with monetary amounts displayed to two decimal places.

Documentation and usability — 5%: Explains the formula, assumptions, and how to run the solution.