-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.html
More file actions
34 lines (34 loc) · 986 Bytes
/
Copy pathcalculator.html
File metadata and controls
34 lines (34 loc) · 986 Bytes
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
<!DOCTYPE html>
<html>
<title>
Basic Calculator
</title>
<body>
<h1>Basic Calculator </h1>
<hr color="purple">
<p id="demo"></p>
<script>
var num1,result;
num1 = parseInt(prompt("num1 : "));
num2=parseInt(prompt("num2 : "));
operatorchoosen=prompt("Type operator ( '+' , '-' , '*' , '/' ) : ");
if(operatorchoosen=='+')
{
result=num1+num2;
}
if(operatorchoosen=='-')
{
result=num1-num2;
}
if(operatorchoosen=='/')
{
result=num1/num2;
}
if(operatorchoosen=='*')
{
result=num1*num2;
}
document.getElementById("demo").innerHTML="Answer is : "+result;
</script>
</body>
</html>