Colorful Normal Calculator
About this app
A fun and colorful normal calculator app with responsive design and basic arithmetic operations.
Beans Calculator 0 2 3 5 + 10 20 C =
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>Beans Calculator</title>
<meta name="description" content="A fun and colorful calculator app specifically designed for calculating beans and their quantities.">
<meta name="keywords" content="beans calculator, vegetable calculator, quantity, web app, fun calculator">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.6.0/css/fontawesome.min.css" crossorigin="anonymous">
<script type="text/javascript">
try {
let currentInput = "";
function appendToInput(value) {
currentInput += value;
updateResult();
}
function clearInput() {
currentInput = "";
updateResult();
}
function calculate() {
try {
const inputArr = currentInput.split(/[\+\-\*\/]/g);
const totalBeans = inputArr.reduce((acc, curr) => acc + (parseInt(curr) || 0), 0);
currentInput = totalBeans.toString();
} catch (error) {
currentInput = "Error";
}
updateResult();
}
function updateResult() {
document.getElementById('result').innerText = currentInput || "0";
}
document.addEventListener("DOMContentLoaded", function() {
const buttons = document.querySelectorAll('.calc-button');
buttons.forEach(button => {
button.addEventListener('click', function () {
const value = this.getAttribute('data-value');
if (value === '=') {
calculate();
} else if (value === 'C') {
clearInput();
} else {
appendToInput(value);
}
});
});
});
} catch (error) {
throw error;
}
</script>
<style>
body {
background: linear-gradient(135deg, #fff0e6, #ffe6e6);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Roboto', sans-serif;
}
#main-container {
background: white;
border-radius: 15px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
padding: 20px;
width: 350px;
}
#result {
font-size: 2.5em;
color: #2d6424;
text-align: right;
padding: 15px;
border: 2px solid #cdcdcd;
margin-bottom: 20px;
background: #f9f7f2;
border-radius: 10px;
}
.calc-button {
background: #5cb85c;
color: white;
border: none;
border-radius: 5px;
padding: 20px;
margin: 5px;
font-size: 24px;
cursor: pointer;
transition: background 0.3s;
outline: none;
}
.calc-button:hover {
background: #4cae4c;
}
.calc-button:active {
background: #3e841e;
}
.operator {
background: #d9534f;
}
.operator:hover {
background: #c9302c;
}
.operator:active {
background: #ac2925;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<div id="result">0</div>
<div class="text-center">
<button class="calc-button" data-value="2">2</button>
<button class="calc-button" data-value="3">3</button>
<button class="calc-button" data-value="5">5</button>
<button class="calc-button operator" data-value="+">+</button>
</div>
<div class="text-center">
<button class="calc-button" data-value="10">10</button>
<button class="calc-button" data-value="20">20</button>
<button class="calc-button" data-value="C">C</button>
<button class="calc-button operator" data-value="=">=</button>
</div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!