forked from Pooja9824/Javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimple Calculator using Prompt Box.html
53 lines (47 loc) · 1.35 KB
/
Simple Calculator using Prompt Box.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
<html>
<head>
<title>Simple Calculation using prompt Box</title>
</head>
<body>
<script>
// declareing variable
var num1, num2;
var operator;
var sum, subtraction, multiplication, devision;
// Input Values
num1 = parseInt(prompt("Enter value of 1st Number", "10"));
operator = prompt("Enter any Arithmetic operator", "+,-,*,/");
num2 = parseInt(prompt("Enter value of 2nd Number", "20"));
// Display Inputed Values
document.write("value of a is=" + num1 + " Arithmetic operator is=" + operator + " value of b is=" + num2 + "<br>");
// Addition
if (operator == "+") {
sum = num1 + num2;
document.write("sum of value is= " + sum + "<br>");
document.write("Completed");
}
// Substraction
else if (operator == "-") {
subtraction = num1 - num2;
document.write("subtraction of value is= " + subtraction + "<br>");
document.write("Completed");
}
// Multiplication
else if (operator == "*") {
multiplication = num1 * num2;
document.write("multiplication of value is= " + multiplication + "<br>");
document.write("Completed");
}
// Division
else if (operator == "/") {
division = num1 / num1;
document.write("division of value is= " + division + "<br>");
document.write("Completed");
}
// if you not enter proper value
else {
document.write("Enter proper value")
}
</script>
</body>
</html>