I write in code,I create app and other useful thing like calculator
HTML
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
}
.calculator {
width: 300px;
margin: 0 auto;
border: 2px solid #ccc;
border-radius: 5px;
padding: 20px;
}
input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
input[type="button"] {
width: 45px;
height: 45px;
margin: 5px;
font-size: 18px;
border-radius: 5px;
border: 1px solid #ccc;
cursor: pointer;
}
</style>
</head>
<body>
<div class="calculator">
<input type="text" id="display" readonly>
<br>
<input type="button" value="7" onclick="appendToDisplay('7'">
<input type="button" value="8" onclick="appendToDisplay('8'">
<input type="button" value="9" onclick="appendToDisplay('9'">
<input type="button" value="/" onclick="appendToDisplay('/'">
<br>
<input type="button" value="4" onclick="appendToDisplay('4'">
<input type="button" value="5" onclick="appendToDisplay('5'">
<input type="button" value="6" onclick="appendToDisplay('6'">
<input type="button" value="*" onclick="appendToDisplay('*'">
<br>
<input type="button" value="1" onclick="appendToDisplay('1'">
<input type="button" value="2" onclick="appendToDisplay('2'">
<input type="button" value="3" onclick="appendToDisplay('3'">
<input type="button" value="-" onclick="appendToDisplay('-'">
<br>
<input type="button" value="0" onclick="appendToDisplay('0'">
<input type="button" value="." onclick="appendToDisplay('.'">
<input type="button" value="=" onclick="calculate()">
<input type="button" value="+" onclick="appendToDisplay('+'">
<br>
<input type="button" value="C" onclick="clearDisplay()">
</div>
<script>
function appendToDisplay(value) {
document.getElementById("display".value += value;
}
function calculate() {
let expression = document.getElementById("display".value;
let result = eval(expression);
document.getElementById("display".value = result;
}
function clearDisplay() {
document.getElementById("display".value = "";
}
</script>
</body>
</html>
```
This HTML code creates a simple calculator with basic arithmetic operations. You can click on the buttons to input numbers and operators, and the result will be displayed on the text input.
Nathaniel Kassah
Delete Comment
Are you sure that you want to delete this comment ?