A financial calculator for computing mortgage payments based on down payment, interest rate, and loan length.
- Calculate monthly mortgage payments
- Display total payment and interest over the life of the loan
- Show detailed amortization schedule
- Format results as currency and percentages
- Node.js (v14 or higher recommended)
- npm
Clone the repository, then either:
./setup.sh
npm install
npm run build
Run the application using:
npm start
Follow the interactive prompts to:
- Enter the total property price
- Specify your down payment amount
- Enter the annual interest rate (as a percentage)
- Provide the loan term in years
The calculator will then display:
- Monthly payment amount
- Total payments over the life of the loan
- Total interest paid
- Optional amortization schedule with payment breakdown
The calculator uses the standard mortgage payment formula:
M = P * [r(1+r)^n] / [(1+r)^n - 1]
Where:
- M = monthly payment
- P = principal (loan amount)
- r = monthly interest rate (annual rate divided by 12)
- n = number of payments (loan term in years * 12)
Build the TypeScript project:
npm run build
The compiled JavaScript files will be output to the dist
directory.
Run the test suite to verify the calculator works correctly:
npm test
This will run a series of tests to validate:
- Standard mortgage calculation
- Zero interest rate calculation
- Amortization schedule generation
The project includes VS Code launch configurations for debugging:
- Launch Mortgage Calculator - Runs the main calculator with the interactive CLI
- Run Tests - Runs the test suite with the debugger attached
To start debugging:
- Open the Debug panel in VS Code (Ctrl+Shift+D or Cmd+Shift+D on Mac)
- Select the configuration you want to run from the dropdown
- Click the green play button or press F5
ISC