Skip to content

Commit

Permalink
Added Dividend Yield Calculator (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meetjain1 authored Jun 11, 2024
1 parent e688c8b commit 21e071b
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Calculators/Dividend-Yield-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# <p align="center">Dividend Yield Calculator</p>

## Description :-

This calculator effortlessly calculates the % Dividend yield which is used to assess potential income from investments, compare dividend-paying stocks, and make informed investment decisions based on risk and long-term financial goals.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/81514639-8920-465f-aaa6-0dc1dcbdc3f4)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Calculators/Dividend-Yield-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
<title>Dividend Yield Calculator</title>
</head>
<body>
<div class="container animate__animated animate__fadeIn">
<h1>Dividend Yield Calculator</h1>
<form id="dividendForm" class="animate__animated animate__zoomIn">
<div class="input-group">
<label for="annualDividend">Annual Dividend (INR):</label>
<input type="number" id="annualDividend" step="0.01" required>
</div>
<div class="input-group">
<label for="marketPrice">Current Market Price (INR):</label>
<input type="number" id="marketPrice" step="0.01" required>
</div>
<button type="submit">Calculate</button>
</form>
<div id="result" class="result animate__animated animate__fadeInUp"></div>
</div>
<script src="script.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions Calculators/Dividend-Yield-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
document.getElementById('dividendForm').addEventListener('submit', function(event) {
event.preventDefault();

const annualDividend = parseFloat(document.getElementById('annualDividend').value);
const marketPrice = parseFloat(document.getElementById('marketPrice').value);

if (isNaN(annualDividend) || isNaN(marketPrice)) {
document.getElementById('result').innerText = "Please enter valid numbers.";
return;
}

const dividendYield = ((annualDividend / marketPrice) * 100).toFixed(2);

document.getElementById('result').innerHTML = `
Dividend Yield: ${dividendYield}%
`;
});
84 changes: 84 additions & 0 deletions Calculators/Dividend-Yield-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
body {
font-family: 'Arial', sans-serif;
background-image: url('assets/background.jpg');
background-size: cover;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
padding: 20px;
}

.container {
background: rgba(193, 214, 75, 0.9);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
text-align: center;
width: 100%;
max-width: 400px;
}

h1 {
margin-bottom: 20px;
font-size: 1.8rem;
color: #333;
}

.input-group {
margin-bottom: 20px;
}

.input-group label {
display: block;
margin-bottom: 5px;
font-size: 1rem;
color: #555;
}

.input-group input {
width: calc(100% - 20px);
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}

button {
padding: 12px 25px;
border: none;
border-radius: 5px;
background: #1d1d1c;
color: white;
font-size: 1.1rem;
cursor: pointer;
transition: background 0.3s ease;
}

button:hover {
background: #e08309;
}

.result {
margin-top: 20px;
font-size: 1.2rem;
color: #333;
font-weight: bold;
}

@media (max-width: 768px) {
h1 {
font-size: 1.5rem;
}

button {
padding: 10px 20px;
font-size: 1rem;
}

.input-group input {
font-size: 0.9rem;
}
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,20 @@ <h3>Unlock Savings with Precision: Your Ultimate Discount Calculator.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Dividend Yield Calculator</h2>
<h3>Calculates the dividend yield percentage based on the current market price.</h3>
<div class="card-footer">
<a href="./Calculators/Dividend-Yield-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Dividend-Yield-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Dora Calculator</h2>
Expand Down

0 comments on commit 21e071b

Please sign in to comment.