Professional Documents
Culture Documents
Calculator
Calculator
TECHNOLOGY
ABSTRACT:
Our project name is Calculator. It is a machine which allows people to do
math operations more easily. For example, most calculators will add,
subtract, multiply, and divide. Some also do square roots, and more complex
calculators can help with calculus and draw function graphs. Calculators are
found everywhere.
Step 1: -
The journey begins with the creation of the structural foundation of our
calculator through HTML. HTML, the markup language of the web, gives
structure to our project. Below is a snippet of the HTML code that sets the
stage for our calculator.
Step 2: -
With the foundation laid, it’s time to add the visual charm that CSS
provides. CSS brings aesthetics and layout to our calculator, making it
visually appealing to users. Here’s a snippet of the CSS code that gives life
to our calculator’s appearance
Step 3: -
JavaScript is the magic wand that imparts interactivity to our calculator. It’s
the powerhouse that makes calculations possible at the click of a button.
Below, we’ll dissect the code segments that give life to our calculator’s
functionalities.
OUTPUT
>>>>CODE:
<html>
<head>
<style>
.calculator {
padding: 10px;
border-radius: 1em;
height: 500px;
width: 600px;
margin: auto;
background-color: black;
box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
}
.display-box {
font-family: 'Orbitron', sans-serif;
font-size:20px;
background-color: white;
border: solid black 0.5px;
color: black;
border-radius: 20px;
width: 100%;
height: 95%;
}
#btn {
font-size:20px;
background-color: red;
}
input[type=button] {
font-size:30px;
font-family: 'Orbitron', sans-serif;
background-color: tan;
color: white;
border: solid black 0.5px;
width: 100%;
border-radius: 5px;
height: 90%;
outline: none;
}
input:active[type=button] {
background: blue;
-webkit-box-shadow: inset 0px 0px 5px #c1c1c1;
-moz-box-shadow: inset 0px 0px 5px #c1c1c1;
box-shadow: inset 0px 0px 5px #c1c1c1;
</style>
<title>Calculator</title>
</head>
<body background="C:\Dev\images\image 1.jpg">
<tr>
<tr>
<td> <input type="button" value="4" onclick="display('4')" /> </td>
<td> <input type="button" value="5" onclick="display('5')" /> </td>
<td> <input type="button" value="6" onclick="display('6')" /> </td>
<td> <input type="button" value="-" onclick="display('-')" /> </td>
</tr>
<tr>
<td> <input type="button" value="7" onclick="display('7')" /> </td>
<td> <input type="button" value="8" onclick="display('8')" /> </td>
<td> <input type="button" value="9" onclick="display('9')" /> </td>
<td> <input type="button" value="+" onclick="display('+')" /> </td>
</tr>
<tr>
<td> <input type="button" value="." onclick="display('.')" /> </td>
<td> <input type="button" value="0" onclick="display('0')" /> </td>
<!-- calculate() function evaluates the mathematical expression -->
<td> <input type="button" value="=" onclick="calculate()" id="btn" /> </td>
<td> <input type="button" value="*" onclick="display('*')" /> </td>
</tr>
</table>
<script language="javascript">
function clearScreen() {
document.getElementById("result").value = "";
}
function display(value) {
document.getElementById("result").value += value;
}
function calculate() {
var p = document.getElementById("result").value;
var q = eval(p);
document.getElementById("result").value = q;
}
</script>
</body>
</html>
Learning Outcomes:
After making this mini project the student will able use the :-
a) Html
b) CSS (Cascading Style sheet)
c) JavaScript
References:
a) https://medium.com/@bhageshwaree11/building-a-basic-calculator-using-
html-css-and-javascript-346ac49a7f58
b) https://www.geeksforgeeks.org/html-calculator/