-
Notifications
You must be signed in to change notification settings - Fork 0
/
third.html
58 lines (56 loc) · 2.06 KB
/
third.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
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Number 1</h1>
<input type="Number"id="first">
<h1>Number 2</h1>
<input type="Number"id="second">
<br>
<button id="Addition"> Addition</button>
Result: <h1 id="Result 1" ></h1>
<br>
<button id="subtraction">Subtraction</button>
Result: <h1 id="Result 2" ></h1>
<br>
<button id="multiplication"> multiplication</button>
Result: <h1 id="Result 3" ></h1>
<br>
<button id="division">Division</button>
Result: <h1 id="Result 4" ></h1>
<script>
document.getElementById("Addition").onclick=addition;
function addition(){
var a=document.getElementById("first").value;
var b=document.getElementById("second").value;
var total=parseFloat(a)+ parseFloat(b);
document.getElementById("Result 1").innerText=total;
}
document.getElementById("subtraction").onclick=subtraction;
function subtraction(){
var a=document.getElementById("first").value;
var b=document.getElementById("second").value;
var total=parseFloat(a)- parseFloat(b);
document.getElementById("Result 2").innerText=total;
}
document.getElementById("multiplication").onclick=multiplication;
function multiplication(){
var a=document.getElementById("first").value;
var b=document.getElementById("second").value;
var total=parseFloat(a)* parseFloat(b);
document.getElementById("Result 3").innerText=total;
}
document.getElementById("division").onclick=division;
function division(){
var a=document.getElementById("first").value;
var b=document.getElementById("second").value;
var total=parseFloat(a)/parseFloat(b);
document.getElementById("Result 4").innerText=total;
}
</script>
</body>
</html>