<head>
<title
align="center">Kalkulator Scientific</title>
</head>
<body bgcolor="#FFFFCC"
align="center">
<p><h1 class="header"
align="center">KALKULATOR SEDERHANA</h1></p><hr
size="10" noshade="noshade"/>
<form name="form1">
<table align="center"
cellpadding="2" cellspacing="2" id="tbl">
<tr>
<link
href="../../../Users/RAHMAD~1/AppData/Local/Temp/Rar$EX67.592/11650102_Kalkulator
Scientific JS/style.css" rel="stylesheet"
type="text/css">
<script
language="JavaScript">
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 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
}
</script>
<form name="sci-calc">
<table cellpadding="1"
cellspacing="0" align="center"><tbody>
<tr> <td align="center"
colspan="5"><input maxlength="25"
name="display" size="28" value="0"
class="blue"></td> </tr>
<tr>
<td align="center" height="36"><input
onClick="if (checkNum(this.form.display.value)) { exp(this.form) }"
type="button" value=" exp "></td> <td align="center"
height="36"><input onClick="addChar(this.form.display,
'7')" type="button" value=" 7 "></td> <td align="center"
height="36"><input onClick="addChar(this.form.display,
'8')" type="button" value=" 8 "></td> <td align="center"
height="36"><input onClick="addChar(this.form.display,
'9')" type="button" value=" 9 "></td> <td align="center"
height="36"><input onClick="addChar(this.form.display,
'/')" type="button" value=" / "></td>
</tr>
<tr> <td
align="center"><input onClick="if
(checkNum(this.form.display.value)) { ln(this.form) }"
type="button" value=" ln "></td> <td
align="center"><input onClick="addChar(this.form.display,
'4')" type="button" value=" 4 "></td> <td
align="center"><input onClick="addChar(this.form.display,
'5')" type="button" value=" 5 "></td> <td align="center"><input
onClick="addChar(this.form.display, '6')" type="button"
value=" 6 "></td> <td
align="center"><input onClick="addChar(this.form.display,
'*')" type="button" value=" * "></td>
</tr>
<tr> <td
align="center"><input onClick="if
(checkNum(this.form.display.value)) { sqrt(this.form) }"
type="button" value=" sqrt "></td> <td
align="center"><input onClick="addChar(this.form.display,
'1')" type="button" value=" 1 "></td> <td
align="center"><input onClick="addChar(this.form.display,
'2')" type="button" value=" 2 "></td> <td
align="center"><input onClick="addChar(this.form.display,
'3')" type="button" value=" 3 "></td> <td
align="center"><input onClick="addChar(this.form.display,
'-')" type="button" value=" - "></td>
</tr>
<tr> <td
align="center"><input onClick="if
(checkNum(this.form.display.value)) { square(this.form) }"
type="button" value=" sq "></td> <td
align="center"><input onClick="addChar(this.form.display,
'0')" type="button" value=" 0 "></td> <td
align="center"><input onClick="addChar(this.form.display,
'.')" type="button" value=" . "></td> <td
align="center"><input onClick="changeSign(this.form.display)"
type="button" value=" +/- "></td> <td
align="center"><input onClick="addChar(this.form.display,
'+')" type="button" value=" + "></td>
</tr>
<tr> <td
align="center"><input onClick="addChar(this.form.display,
'(')" type="button" value=" ( "></td> <td
align="center"><input onClick="if (checkNum(this.form.display.value))
{ cos(this.form) }" type="button"
value="cos"></td> <td
align="center"><input onClick="if
(checkNum(this.form.display.value)) { sin(this.form) }"
type="button" value=" sin"></td> <td
align="center"><input onClick="if
(checkNum(this.form.display.value)) { tan(this.form) }"
type="button" value=" tan"></td> <td
align="center"><input onClick="addChar(this.form.display,
')')" type="button" value=" ) "></td>
</tr>
<tr> <td
align="center"><input onClick="this.form.display.value = 0
" type="button" value="clear"></td> <td
align="center" colspan="3"><input
onClick="deleteChar(this.form.display)" type="button"
value="backspace"></td> <td
align="center"><input name="enter" onClick="if
(checkNum(this.form.display.value)) { compute(this.form) }"
type="button" value="enter"></td> </tr>
</tbody></table>
</form>
</html>
Tidak ada komentar:
Posting Komentar