-
Notifications
You must be signed in to change notification settings - Fork 59
/
calculater html
51 lines (44 loc) · 1.34 KB
/
calculater html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<head>
<title>Calculator</title>
</head>
</style>
<body> <div align="center">
<h1>My Calculator</h1>
<label style="padding-right: 100px;"> Number 1</label>
<label style="padding-right: 130px;"> Symbol</label>
<label> Number 2</label>
<form>
<input type="text" id="value1" name="value1">
<input type="text" id="sign" name="sign">
<input type="text" id="value2" name="value2">
<br/>
<input type="button" value="calculate" name="result" onclick="calculate()">
</form>
<br>
<script>
const calculate =() => {
var value1, value2, result, sign;
value1=Number(document.getElementById("value1").value);
value2=Number(document.getElementById("value2").value);
sign=(document.getElementById("sign").value);
if(sign =="+") {
result= (document.getElementById("result").innerHTML= "result" + (value1+value2));
}
else if(sign =="-") {
result= (document.getElementById("result").innerHTML=value1-value2);
}
else if(sign =="/") {
result= (document.getElementById("result").innerHTML=value1/value2);
}
else if(sign =="*") {
result= (document.getElementById("result").innerHTML="Your Calculated value is: " + (value1*value2));
}else {
result = document.getElementById("result").innerHTML = "Your Enter The wrong Symbol";
}
}
</script>
<h3 id="result"></h3>
</div>
</body>
</html>