Currency Calculator
About this app
Calculate the total number of notes and coins for a given amount
Currency Calculator Currency Calculator Enter Amount: Calculate Result:
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Currency Calculator</title>
<meta name="description" content="Calculate the total number of notes and coins for a given amount">
<meta name="keywords" content="currency calculator, notes, coins">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<script type="text/javascript">
try {
// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Calculate the number of notes and coins
function calculateNotesAndCoins() {
var amount = parseFloat($("#amount").val());
var notes = {
"$100": 0,
"$50": 0,
"$20": 0,
"$10": 0,
"$5": 0
};
var coins = {
"$2": 0,
"$1": 0,
"$0.50": 0,
"$0.25": 0,
"$0.10": 0,
"$0.05": 0
};
// Calculate the number of notes
for (var note in notes) {
if (amount >= parseFloat(note.substring(1))) {
notes[note] = Math.floor(amount / parseFloat(note.substring(1)));
amount = amount % parseFloat(note.substring(1));
}
}
// Calculate the number of coins
for (var coin in coins) {
if (amount >= parseFloat(coin.substring(1))) {
coins[coin] = Math.floor(amount / parseFloat(coin.substring(1)));
amount = amount % parseFloat(coin.substring(1));
}
}
// Display the results
var result = "";
for (var note in notes) {
if (notes[note] > 0) {
result += notes[note] + " " + note + " ";
}
}
for (var coin in coins) {
if (coins[coin] > 0) {
result += coins[coin] + " " + coin + " ";
}
}
$("#result").text(result);
}
// Event listener for the calculate button
$("#calculate-button").click(function() {
calculateNotesAndCoins();
});
});
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
<style>
body {
background-color: #f8f9fa;
font-family: 'Roboto', sans-serif;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #000000;
text-align: center;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
.form-control {
height: 40px;
}
.btn {
width: 100%;
height: 40px;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Currency Calculator</h1>
<div class="form-group">
<label for="amount">Enter Amount:</label>
<input type="number" id="amount" class="form-control" step="0.01" min="0">
</div>
<button id="calculate-button" class="btn btn-primary">Calculate</button>
<div class="form-group mt-3">
<label for="result">Result:</label>
<p id="result"></p>
</div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!