-
Notifications
You must be signed in to change notification settings - Fork 47
/
simple calculator webapp.html
117 lines (99 loc) · 3.55 KB
/
simple calculator webapp.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<title>Basic calculator using js by Anand Prabhakar</title>
<style>
*{text-align: center;
margin: 0px;
}
#advanced{
display: none;
}
html{background: yellow;}
.calc{background: red;
padding: 20px;
color: yellow;
}
input{
background-color: blue;
color: yellow;
}
button{
background: green;
color: yellow;
width: 20%;
height: 30px;
margin-right: 20px;
}
button:hover{
background: yellow;
color: red;
scale :2;
}
</style>
<script>
function sumthem(){
var x,y,sum;
x = Number(document.getElementById('a').value);
y = Number(document.getElementById('b').value);
sum = x+y;
document.getElementById("display").innerHTML ="The Sum of Numbers "+x+" and "+y+" is "+sum;
}
function subthem(){
var x,y,sum;
x = Number(document.getElementById('a').value);
y = Number(document.getElementById('b').value);
sub = x-y;
document.getElementById("display").innerHTML ="The Difference of Numbers "+x+" and "+y+" is "+sub;
}
function multthem(){
var x,y,sum;
x = Number(document.getElementById('a').value);
y = Number(document.getElementById('b').value);
mult = x*y;
document.getElementById("display").innerHTML ="The product of Numbers "+x+" and "+y+" is "+mult;
}
function divthem(){
var x,y,sum;
x = Number(document.getElementById('a').value);
y = Number(document.getElementById('b').value);
q = x/y;
r= x%y;
document.getElementById("display").innerHTML ="The Quotient of Numbers "+x+" ÷ "+y+" is "+q+ " and remainder is "+r;
}
function credit(){
document.getElementById("advanced").style.display = 'block';
document.getElementById("display2").innerHTML = " \n This web app is presented to you by Anand Prabhakar\nFor more info go to https://linkedin.com/in/anand-prabhakar-0507";
}
function powern(){
var x,y;
x = Number(document.getElementById('a').value);
y = Number(document.getElementById('b').value);
document.getElementById("display").innerHTML = +x+ "^" +y+ "=" +(x**y);
}
</script>
</head>
<body>
<h1>Calculator by Anand Prabhakar</h1>
<br>
<div class="calc">
<span></span>Enter First Number : </span><input name="a" id="a" ><br>
<span>Enter Second Number : </span><input name="b" id="b"><br><br>
<span id="display"></span>
<br><br>
<button onclick="sumthem()">+</button>
<button onclick="subthem()">-</button>
<button onclick="multthem()">X</button>
<button onclick="divthem()">÷</button><br><br>
<button onclick="credit()">Advanced</button>
<div id="advanced" >
<div class="calc">
<br>
<button onclick="powern()">Find power</button>
<br><br>
<span id="display2"></span>
</div>
</div>
<br><br>
</body>
</html>