Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/apursley2012/airgead-investment-calculator/llms.txt

Use this file to discover all available pages before exploring further.

The source/ folder preserves the original Airgead Banking console application written in C++. This is the program that the web version was designed to replicate. The console app accepts the same four inputs and prints two formatted reports — one without monthly deposits and one with.

Source Files

FilePurpose
airgeadBankingApp.cppEntry point: collects the four inputs and calls the Investment display methods
investment.hDeclares the Investment class, YearlyInvestmentResult struct, and public interface
investment.cppImplements calculation logic and formatted console report output

Compile and Run

1

Navigate to the source directory

cd source
2

Compile with g++

g++ airgeadBankingApp.cpp investment.cpp -o airgead
3

Run on macOS/Linux

./airgead
4

Run on Windows PowerShell

.\airgead.exe

Sample Session

The following shows what the console application looks like when run with example inputs:
**************************************
********* Airgead Banking ************
**************************************
Initial Investment Amount: $5000
Monthly Deposit: $250
Annual Interest (%): 5
Number of years: 5

Balance and Interest Without Additional Monthly Deposits
==================================================================
Year     Year End Balance       Year End Earned Interest
------------------------------------------------------------------
1        $5,255.81                              $255.81
2        $5,524.71                              $268.89
...

Balance and Interest With Additional Monthly Deposits
==================================================================
Year     Year End Balance       Year End Earned Interest
------------------------------------------------------------------
1        $8,374.33                              $374.33
...

Input Validation

The main loop uses two helper functions to ensure that all user-provided values are valid before constructing the Investment object:
  • readNonNegativeDouble() — used for the starting balance, monthly deposit, and annual interest rate. Repeats the prompt if the input fails to parse or is negative.
  • readPositiveInteger() — used for the number of years. The entered value must be a whole number greater than 0; any other input causes the prompt to repeat.
Both helpers call cin.clear() and cin.ignore() to flush the input stream before retrying, preventing an infinite loop on bad input.

Relationship to the Web Version

The C++ source uses the same monthly compounding formula as the JavaScript version. The key difference is that the C++ calculateWithMonthlyDeposit() adds the deposit before applying interest each month, while the JavaScript version applies interest first then adds the deposit. The final balance figures differ slightly as a result. Both models demonstrate the educational concept of compound growth.

Build docs developers (and LLMs) love