-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.html
More file actions
56 lines (54 loc) · 1.57 KB
/
Copy pathcalculator.html
File metadata and controls
56 lines (54 loc) · 1.57 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Calculator | rowannerd</title>
<link rel="stylesheet" href="https://cascadecoder.github.io/rowannerd.css">
<style>
html {
font-family: sans-serif;
//background-color: rgb(150, 255, 255);
}
.space {
height: 30px;
}
button {
color: white;
background-color: red;
height: 50px;
}
button:hover {
background-color: black;
}
</style>
</head>
<body>
<h1>Calculator | <span id="rowannerd">rowannerd</span></h1>
<b><span>1st number: </span><input type="text" id="a"> <br><br>
<span>Operator (+, -, *, /): </span><input type="text" id="op"> <br><br>
<span>2nd number: </span><input type="text" id="b"> <br><br>
<button onclick="solve()">Solve Equation</button>
<div id="space"></div>
<div id="table"></div>
<script>
function solve() {
var a = document.getElementById("a").value;
var b = document.getElementById("b").value;
var op = document.getElementById("op").value;
a = Number(a);
b = Number(b);
if (op == "+") {
var equals = a + b;
} else if (op == "-") {
var equals = a - b;
} else if (op == "*" || op == "x") {
var equals = a * b
} else if (op == "/") {
var equals = a/b;
} else {
var equals = "Error! Not correct operation!";
}
document.getElementById('table').innerHTML = a + op + b + "" + "=" + equals;
}
</script>
</body>
</html>