Mortgage Calculator
React.js
easy
Create a Mortgage Calculator in React that allows users to input loan amount, interest rate, and loan term (years) to calculate the monthly mortgage payment.
Requirements
-
Must have Input fields for:
- Loan amount (in INR) with label="Loan Amount"
- Annual interest rate (in %) with label="Annual Interest Rate"
- Loan term (in years) with id="Loan Term"
-
Show message "Invalid input" for inappropriate inputs
-
Must have a button labelled "Calculate" to calculate the monthly payment
-
Calculate monthly payment using the formula:
where:
- M = monthly payment
- P = loan principal (loan amount)
- r = monthly interest rate = annual rate / 12 / 100
- n = number of monthly payments = years * 12
-
Display the calculated monthly payment.
-
The result (monthly payment) must have aria-label="result"
Constraints & Edge Cases
- Inputs should be non-negative numbers.
- Interest rate cannot be zero or negative.
- Term should be greater than 0 years.
- Monthly payment should be displayed only if inputs are valid.
Reference UI
Preview what you need to build
Solve Similar questions 🔥