Posts

Fixed Deposit Calculator

Tool-Code
Fixed Deposit Calculator

Fixed Deposit Calculator

Years:
Months:
Days:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Fixed Deposit Calculator</title>
    <style>
              body {
                  font-family: Arial, sans-serif;
                  background-color: #f0f0f0;
                  padding: 0px;
              }
              .container {
                  max-width: 500px;
                  background-color: #fff4f4;
                  padding: 20px;
                  border-radius: 10px;
                  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
              }
              input[type="number"], select {
                  padding: 10px;
                  margin: 10px 0;
                  border: 1px solid #ccc;
                  border-radius: 5px;
                  width: 100%;
              }
              .flex-row {
                  display: flex;
                  justify-content: space-between;
                  gap: 10px;
              }
              .flex-row input[type="number"] {
                  flex: 1;
              }
              .custom-button {
                  background-color: #4CAF50;
                  color: white;
                  padding: 10px;
                  border: none;
                  border-radius: 5px;
                  cursor: pointer;
                  width: 100%;
                text-align: center;
              }
              button:hover {
                  background-color: #45a049;
              }
              .result {
                  margin-top: 20px;
                  font-size: 1.2em;
              }


             h1 {
                  text-align: center;
                  color: white;
                  margin-bottom: 20px;
                  font-size: 30px;
                  letter-spacing: 0px;
                  font-family: system-ui;
                  font-weight: 600;
                  line-height: 1.5em;
                  background: linear-gradient(135deg, #0cf3e9, #ea00ff);
                  padding: 6px;
                  border-radius: 6px;

              }

             h1:hover {

                  background: linear-gradient(136deg, #ea00ff,#0cf3e9);

              }

           label {
          font-size: 16px;
          font-weight: 600;
          color: black;
      }

            input {
          font-size: 16px;

          color: black;
      }


             @media screen and (max-width: 768px) {
          h1 {
              font-size: 20px;
              color: white;
              padding: 11px;
          }
    </style>
  </head>
  <body>
    <div class="container">
      <h1>Fixed Deposit Calculator</h1>

      <label for="principal">Principal Amount (₹):</label>
      <input
        type="number"
        id="principal"
        placeholder="Enter principal amount"
        required
      />

      <label for="rate">Annual Interest Rate (%):</label>
      <input
        type="number"
        id="rate"
        placeholder="Enter interest rate"
        step="0.01"
        required
      />
      <div>
        <label for="time">Time Period:</label>
        <div class="flex-row">
          <div>
            <div style="text-align: center;">
              <span style="color: #990000; font-family: times; font-size: 14px;"
                >Years:</span
              >
            </div>
            <input
              type="number"
              id="timeYears"
              placeholder="Years"
              value="0"
              required
            />
          </div>
          <div>
            <div style="text-align: center;">
              <span style="color: #990000; font-family: times; font-size: 14px;"
                >Months:</span
              >
            </div>
            <input
              type="number"
              id="timeMonths"
              placeholder="Months"
              value="0"
              required
            />
          </div>
          <div>
            <div style="text-align: center;">
              <span style="color: #990000; font-family: times; font-size: 14px;"
                >Days:</span
              >
            </div>
            <input
              type="number"
              id="timeDays"
              placeholder="Days"
              value="0"
              required
            />
          </div>
        </div>
      </div>
      <label for="frequency">Interest Payment Option:</label>
      <select id="frequency">
        <option value="1">Maturity</option>
        <option value="12">Monthly Income</option>
        <option value="4">Quarterly Income</option>
      </select>

      <button class="custom-button" onclick="calculateFD()">Calculate</button>

      <div class="result" id="result"></div>
    </div>

    <script>
      function calculateFD() {
          // Get input values
          var principal = parseFloat(document.getElementById('principal').value);
          var rate = parseFloat(document.getElementById('rate').value) / 100;
          var timeYears = parseFloat(document.getElementById('timeYears').value) || 0;
          var timeMonths = parseFloat(document.getElementById('timeMonths').value) || 0;
          var timeDays = parseFloat(document.getElementById('timeDays').value) || 0;
          var frequency = parseInt(document.getElementById('frequency').value);

          // Convert months and days to years
          var time = timeYears + (timeMonths / 12) + (timeDays / 365);

          // Check if input values are valid
          if (isNaN(principal) || isNaN(rate) || isNaN(time) || principal <= 0 || rate <= 0 || time <= 0) {
              document.getElementById('result').innerHTML = "Please enter valid values.";
              return;
          }

          // Calculate maturity amount using compound interest formula
          var maturityAmount = principal * Math.pow((1 + rate / frequency), frequency * time);
          maturityAmount = maturityAmount.toFixed(2); // Limit to two decimal places

          // Display the result
          document.getElementById('result').innerHTML = "Maturity Amount: ₹" + maturityAmount;
      }
    </script>
  </body>
</html>

Post a Comment