Skip to content

Commit

Permalink
Added rupees value in Real Estate Calculator (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshitaJangde authored Jun 10, 2024
1 parent 05f77a6 commit 49813b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Calculators/Real-Estate-Calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
<div class="calculator-container">
<h1>Real Estate Calculator</h1>
<div>
<label for="propertyValue">Property Value ($):</label>
<label for="propertyValue">Property Value:</label>
<!-- adding the option to select currency -->
<select id="currency">
<option value="USD">USD ($)</option>
<option value="INR">INR (₹)</option>
</select>
<input type="number" id="propertyValue" placeholder="Enter property value">

</div>
<div>
<label for="downPayment">Down Payment (%):</label>
Expand Down
10 changes: 8 additions & 2 deletions Calculators/Real-Estate-Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ function calculateMortgage() {

var monthlyPayment = (loanAmount * monthlyInterestRate) / (1 - Math.pow(1 + monthlyInterestRate, -numberOfPayments));

var currency = document.getElementById("currency").value;
var currencySymbol = currency === "USD" ? "$" : "₹";

// Display the result
document.getElementById("result").innerHTML =
"Loan Amount: $" + loanAmount.toFixed(2) + "<br>" +
"Monthly Payment: $" + monthlyPayment.toFixed(2);
"Loan Amount("+currencySymbol+"): " + loanAmount.toFixed(2) + "<br>" +
"Monthly Payment("+currencySymbol+"): " + monthlyPayment.toFixed(2);
}

// Added an event listener to update results when currency is changed
document.getElementById("currency").addEventListener("change", calculateMortgage);
10 changes: 9 additions & 1 deletion Calculators/Real-Estate-Calculator/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ body {
height: 100vh;
}

#currency {
border: 2px solid black;
border-radius: 50px;
width: 65px;
font-size: 12px;
font-weight: bold;
}

.calculator-container {
background-color: #fff;
padding: 20px;
Expand All @@ -34,4 +42,4 @@ button:hover {
input {
padding: 8px;
margin: 5px;
}
}

0 comments on commit 49813b0

Please sign in to comment.