A simple command-line Java program that calculates monthly mortgage payments based on user input.
- Takes user input for:
- Loan principal amount
- Annual interest rate (percentage)
- Loan term in years
- Validates inputs within sensible ranges
- Calculates monthly mortgage payments using the standard amortization formula
- Handles zero interest rate as a special case
- Displays monthly payment formatted as currency
- Java Development Kit (JDK) 11 or higher
- Command line terminal or IDE supporting Java
-
Clone or download this repository.
-
Open a terminal and navigate to the project folder.
-
Compile the Java source code:
javac src/MortgageCalculator.java -d bin
-
Run the program:
java -cp bin MortgageCalculator
-
Follow the on-screen prompts to input:
- Principal amount (between $1,000 and $1,000,000)
- Annual interest rate (1% to 30%)
- Loan term in years (1 to 30)
Welcome to the Mortgage Calculator!
Please enter the principal (numbers only): 250000
Annual Interest Rate (no percent symbol): 3.5
Length of mortgage in years: 30
Your monthly mortgage payment is: $1122.61