Scientific Calculator
About this app
A fun and interactive scientific calculator for advanced calculations.
Scientific Calculator Scientific Calculator 0 1 2 3 + 4 5 6 - 7 8 9 * C 0 = / sin cos tan π √ ^
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>Scientific Calculator</title>
<meta name="description" content="A fun and interactive scientific calculator for advanced calculations.">
<meta name="keywords" content="Calculator, Scientific Calculator, Math, Advanced Calculations, JavaScript Calculator">
<!-- Libraries -->
<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 {
document.addEventListener("DOMContentLoaded", function() {
let resultDisplay = document.getElementById("result");
let buttons = document.querySelectorAll(".btn");
let currentInput = "";
buttons.forEach(button => {
button.addEventListener("click", function() {
handleButtonClick(this.innerText);
});
});
function handleButtonClick(value) {
if (value === "C") {
currentInput = "";
} else if (value === "=") {
try {
currentInput = eval(currentInput);
} catch {
currentInput = "Error";
}
} else {
currentInput += value;
}
updateDisplay();
}
function updateDisplay() {
resultDisplay.innerText = currentInput === "" ? "0" : currentInput;
}
});
} catch (error) {
throw error;
}
</script>
<style>
body {
background: linear-gradient(to right, #ffccbc, #d2a6ff);
}
#main-container {
margin-top: 50px;
}
#result {
background: #ffffff;
border: 2px solid #f06292;
height: 80px;
font-size: 2em;
display: flex;
align-items: center;
justify-content: flex-end;
padding: 10px;
margin-bottom: 20px;
border-radius: 10px;
}
.btn {
margin: 5px;
background-color: #f48fb1;
color: white;
font-size: 1.5em;
}
.btn:hover {
background-color: #ec407a;
transition: background-color 0.3s;
}
</style>
</head>
<body>
<div id="main-container" class="container text-center">
<h1 class="mb-4">Scientific Calculator</h1>
<div id="result">0</div>
<div class="row">
<div class="col">
<button class="btn col-12">1</button>
</div>
<div class="col">
<button class="btn col-12">2</button>
</div>
<div class="col">
<button class="btn col-12">3</button>
</div>
<div class="col">
<button class="btn col-12">+</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn col-12">4</button>
</div>
<div class="col">
<button class="btn col-12">5</button>
</div>
<div class="col">
<button class="btn col-12">6</button>
</div>
<div class="col">
<button class="btn col-12">-</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn col-12">7</button>
</div>
<div class="col">
<button class="btn col-12">8</button>
</div>
<div class="col">
<button class="btn col-12">9</button>
</div>
<div class="col">
<button class="btn col-12">*</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn col-12">C</button>
</div>
<div class="col">
<button class="btn col-12">0</button>
</div>
<div class="col">
<button class="btn col-12">=</button>
</div>
<div class="col">
<button class="btn col-12">/</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn col-12">sin</button>
</div>
<div class="col">
<button class="btn col-12">cos</button>
</div>
<div class="col">
<button class="btn col-12">tan</button>
</div>
<div class="col">
<button class="btn col-12">π</button>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn col-12">√</button>
</div>
<div class="col">
<button class="btn col-12">^</button>
</div>
</div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!