To design a web application for a standard calculator with minimum five operations.
Clone the github repository and create Django admin interface.
Change settings.py file to allow request from all hosts.
Use CSS for creating attractive colors.
Write JavaScript program for implementing five different operations.
Validate the HTML and CSS code.
Publish the website in the given URL.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<script>
function display(val) {
document.getElementById('result').value += val;
}
function SolveCalculation() {
var x = document.getElementById('result').value;
var y = eval(x);
document.getElementById('result').value = y;
}
function ClearFuntion() {
document.getElementById('result').value = ''
}
function deleteFuntion() {
var temp = ''
temp = document.getElementById('result').value;
var len = temp.length;
temp = temp.substring(0, len - 1)
document.getElementById('result').value = temp;
}
function squareRoot(){
var x = document.getElementById('result').value ;
var result = Math.pow(x,0.5)
document.getElementById('result').value=result
}
</script>
<style>
.App-container {
padding: 100px;
margin-top: 5%;
line-height: 55px;
border: none;
border-radius: 5px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.6), 0 6px 20px 0 rgba(0, 0, 0, 0.39);
margin-left: 25%;
margin-right: 25%;
text-align: center;
background-color: pink;
}
#h1{
text-align: center;
}
#numberButton,
#operatorButton,
#clearButton,
#deleteButton {
padding: 20px;
margin-top: 8px;
margin-left: 10px;
border: 5px;
cursor: pointer;
border-radius: 5px;
}
#EqualButton {
border-radius: 5px;
height: 57px;
border: 5px;
padding-left: 10px;
background-color: rgb(155, 197, 61);
font-size: 20px;
font-weight: 500;
}
#result {
border-radius: 5px;
height: 55px;
border: 5px;
padding-left: 15px;
color: black;
font-size: 28px;
font-weight: 500;
}
#operatorButton {
background-color: rgb(245, 165, 114);
}
#deleteButton {
background-color: rgb(255, 108, 92);
}
#clearButton {
background-color: rgb(155, 81, 81);
}
.lastdiv {
margin-left: 3px;
}
@media(max-width:580px) {
.App-container {
padding: 20px 0px;
margin: 50% 6%;
}
}
</style>
</head>
<body>
<div class="App-container">
<h1>Ezhil sree Calculator</h1>
<h1>Reg No:212223230056</h1>
<input type="text" id="result" placeholder="Enter Value..." readonly="" />
<input type="button" id="EqualButton" value="Ans" onclick="SolveCalculation()" />
<div>
<input type="button" id="numberButton" value="7" onclick="display('7')" />
<input type="button" id="numberButton" value="8" onclick="display('8')" />
<input type="button" id="numberButton" value="9" onclick="display('9')" />
<input type="button" id="operatorButton" value="/" onclick="display('/')" />
</div>
<div>
<input type="button" id="numberButton" value="4" onclick="display('4')" />
<input type="button" id="numberButton" value="5" onclick="display('5')" />
<input type="button" id="numberButton" value="6" onclick="display('6')" />
<input type="button" id="operatorButton" value="*" onclick="display('*')" />
</div>
<div>
<input type="button" id="numberButton" value="1" onclick="display('1')" />
<input type="button" id="numberButton" value="2" onclick="display('2')" />
<input type="button" id="numberButton" value="3" onclick="display('3')" />
<input type="button" id="operatorButton" value="-" onclick="display('-')" />
</div>
<div className='lastdiv'>
<input type="button" id="numberButton" value="0" onclick="display('0')" />
<input type="button" id="numberButton" value="." onclick="display('.')" />
<input type="button" id="operatorButton" value="โ" onclick="squareRoot()" />
<input type="button" id="operatorButton" value="+" onclick="display('+')" />
</div>
<div>
<input type="button" id='deleteButton' value="Del" onclick="deleteFuntion()" />
<input type="button" id="clearButton" onclick="ClearFuntion()" value="C" />
</div>
</div>
</body>
</html>
The program for designing a standard calculator using HTML and CSS is executed successfully.