function calculateCAD() {
var usdAmountInput = document.getElementById("usdAmount");
var exchangeRateInput = document.getElementById("exchangeRate");
var resultDisplay = document.getElementById("result");
var usdAmount = parseFloat(usdAmountInput.value);
var exchangeRate = parseFloat(exchangeRateInput.value);
if (isNaN(usdAmount) || isNaN(exchangeRate) || usdAmount < 0 || exchangeRate <= 0) {
resultDisplay.innerHTML = "Please enter valid positive numbers for both USD amount and exchange rate.";
return;
}
var cadAmount = usdAmount * exchangeRate;
resultDisplay.innerHTML = `${usdAmount.toFixed(2)} USD is equal to ${cadAmount.toFixed(2)} CAD.`;
}
.calculator-container {
font-family: sans-serif;
max-width: 500px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.calculator-form h2, .calculator-result h3 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.form-group input[type="number"] {
width: calc(100% – 12px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.calculator-form button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
.calculator-form button:hover {
background-color: #0056b3;
}
#result {
margin-top: 20px;
padding: 10px;
background-color: #e9ecef;
border-radius: 4px;
text-align: center;
font-size: 18px;
color: #333;
}
Understanding Exchange Rates: USD to CAD
An exchange rate is the value of one nation's currency for the purpose of trading for another nation's currency. In this case, we are focusing on the exchange rate between the United States Dollar (USD) and the Canadian Dollar (CAD). This rate fluctuates constantly due to various economic factors, including:
* **Economic Performance:** Stronger economic growth in one country relative to another often leads to a stronger currency.
* **Interest Rates:** Higher interest rates can attract foreign investment, increasing demand for the currency and thus its value.
* **Inflation:** High inflation erodes purchasing power and can weaken a currency.
* **Political Stability:** Countries with stable political environments tend to have more stable currencies.
* **Trade Balances:** A country that exports more than it imports may see its currency appreciate.
The USD to CAD exchange rate is particularly important for businesses and individuals involved in trade, travel, or investment between the United States and Canada. For example, a Canadian tourist visiting the U.S. will want to know how many Canadian dollars they will receive for their U.S. dollars, and vice-versa for an American tourist in Canada.
### How the Calculator Works
Our calculator simplifies this conversion. You need to provide two key pieces of information:
1. **Amount in USD:** This is the exact amount of United States Dollars you wish to convert.
2. **Current USD to CAD Exchange Rate:** This is the most crucial input. It represents how many Canadian Dollars you can get for one U.S. Dollar. For example, if the rate is 1.35, it means 1 USD = 1.35 CAD. You can find current exchange rates from reputable financial news sources or bank websites.
Once you input these values, the calculator multiplies the USD amount by the exchange rate to give you the equivalent amount in Canadian Dollars.
### Example: Converting $100 USD to CAD
Let's say you have **$100 USD** and the current exchange rate is **1 USD = 1.37 CAD**.
* **Amount in USD:** 100
* **Current USD to CAD Exchange Rate:** 1.37
Using the formula:
Amount in CAD = Amount in USD × Exchange Rate
Amount in CAD = 100 × 1.37 = 137 CAD
So, $100 USD would be equivalent to $137 CAD at this exchange rate.
It's important to note that the rates displayed by financial institutions might include a small margin or fee for the actual transaction. This calculator uses the direct rate you provide for simplicity.