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
118
119
120
121
122
123
124
125
126
127
128
129
130
|
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=edge">
<title>Calculator</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="common.css">
<link rel="shortcut icon" href="favicon32.ico" size="32x32">
<script>
function charms(){
document.getElementById('charmsbar').style.display='block';
document.getElementById('datetime').style.display='block';
}
function destroycharms() {
document.getElementById('charmsbar').style.display='none';
document.getElementById('datetime').style.display='none';
}
function start(){
document.getElementById('startbutton').style.display='block';
}
function destroystart() {
document.getElementById('startbutton').style.display='none';
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
<!-- Begin
function addChar(input, character) {
if(input.value == null || input.value == "0")
input.value = character
else
input.value += character
}
function cos(form) {
form.display.value = Math.cos(form.display.value);}
function sin(form) {
form.display.value = Math.sin(form.display.value);}
function tan(form) {
form.display.value = Math.tan(form.display.value);}
function sqrt(form) {
form.display.value = Math.sqrt(form.display.value);}
function ln(form) {
form.display.value = Math.log(form.display.value);}
function exp(form) {
form.display.value = Math.exp(form.display.value);}
function sqrt(form) {
form.display.value = Math.sqrt(form.display.value);}
function deleteChar(input) {
input.value = input.value.substring(0, input.value.length - 1)
}
function changeSign(input) {
if(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}
function compute(form) {
form.display.value = eval(form.display.value)}
function square(form) {
form.display.value = eval(form.display.value) *
eval(form.display.value)}
function checkNum(str) {
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i+1)
if (ch < "0" || ch > "9") {
if (ch != "/" && ch != "*" && ch != "+" && ch !=
"-" && ch != "."
&& ch != "(" && ch!= ")") {
alert("invalid entry!")
return false
}
}
}
return true
}
// End -->
</script>
<div id="scientific" align="center">
<table>
<form></form>
<tbody><tr>
<td colspan="6"><input style="width: 400px;" name="display" value="0"></td>
</tr>
<tr>
<td><input style="width: 90px;" value=" exp " onclick="if (checkNum(this.form.display.value)) {
exp(this.form) }" class="actionbutton" type="button"></td>
<td><input value="7" onclick="addChar(this.form.display, '7')" type="button"></td>
<td><input value="8" onclick="addChar(this.form.display, '8')" type="button"></td>
<td><input value="9" onclick="addChar(this.form.display, '9')" type="button"></td>
<td><input style="width: 60px;" value="/ " onclick="addChar(this.form.display, '/')" class="actionbutton" type="button"></td>
</tr>
<tr>
<td><input style="width: 90px;" value=" ln " onclick="if (checkNum(this.form.display.value)) {
ln(this.form) }" class="actionbutton" type="button"></td>
<td><input value="4" onclick="addChar(this.form.display, '4')" type="button"></td>
<td><input value="5" onclick="addChar(this.form.display, '5')" type="button"></td>
<td><input value="6" onclick="addChar(this.form.display, '6')" type="button"></td>
<td><input style="width: 60px;" value="* " onclick="addChar(this.form.display, '*')" class="actionbutton" type="button"></td>
</tr><tr>
<td><input style="width: 90px;" value=" sqrt " onclick="if (checkNum(this.form.display.value)) {
sqrt(this.form) }" class="actionbutton" type="button"></td>
<td><input value="1" onclick="addChar(this.form.display, '1')" type="button"></td>
<td><input value="2" onclick="addChar(this.form.display, '2')" type="button"></td>
<td><input value="3" onclick="addChar(this.form.display, '3')" type="button"></td>
<td><input style="width: 60px;" value="- " onclick="addChar(this.form.display, '-')" class="actionbutton" type="button"></td>
</tr><tr>
<td><input style="width: 90px;" value=" sq " onclick="if (checkNum(this.form.display.value)) {
square(this.form) }" class="actionbutton" type="button"></td>
<td><input value="0" onclick="addChar(this.form.display, '0')" type="button"></td>
<td><input style="width: 56px;" value=" . " onclick="addChar(this.form.display, '.')" class="actionbutton" type="button"></td>
<td><input style="width: 75px;" value="+/-" onclick="changeSign(this.form.display)" class="actionbutton" type="button"></td>
<td><input style="width: 60px;" value="+" onclick="addChar(this.form.display, '+')" class="actionbutton" type="button"></td>
</tr><tr>
<td><input style="width: 90px;" value=" ( " onclick="addChar(this.form.display, '(')" class="actionbutton" type="button"></td>
<td><input style="width: 75px;" value="cos" onclick="if (checkNum(this.form.display.value)) {
cos(this.form) }" class="actionbutton" type="button"></td>
<td><input value="sin" onclick="if (checkNum(this.form.display.value)) {
sin(this.form) }" class="actionbutton" type="button"></td>
<td><input style="width: 75px;" value="tan" onclick="if (checkNum(this.form.display.value)) {
tan(this.form) }" class="actionbutton" type="button"></td>
<td><input style="width: 60px;" value=" ) " onclick="addChar(this.form.display, ')')" class="actionbutton" type="button"></td>
</tr><tr>
<td><input id="deletebutton" value="Clear" onclick="this.form.display.value = 0 " type="button"></td>
<td><input value="<--" onclick="deleteChar(this.form.display)" class="actionbutton" type="button"></td>
<td><input style="width: 70px;" class="resultbutton" value="=" name="enter" onclick="if (checkNum(this.form.display.value)) { compute(this.form) }" type="button"></td>
</tr></tbody></table>
</div>
</body>
</html>
|