Laman

Selasa, 01 Maret 2011

Kode Program Kalkulator Sederhana

<html>
<head>
<title>Kalkulator Sederhana</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function pengurangan(){
x=eval(form.x.value)
y=eval(form.y.value)
z=x-y
form.hasil.value=z
}

function penjumlahan(){
x=eval(form.x.value)
y=eval(form.y.value)
z=x+y
form.hasil.value = z
}

function perkalian(){
x=eval(form.x.value)
y=eval(form.y.value)
z=x*y
form.hasil.value = z
}

function pembagian(){
x=eval(form.x.value)
y=eval(form.y.value)
z=x/y
form.hasil.value = z
}

function pangkatdua(){
x=eval(form.x.value)
y=eval(form.y.value)
z=Math.pow(x, y)
form.hasil.value = z
}

function rav(){
form.x.focus()
form.x.value=""
form.y.value=""
form.hasil.value=""
}
</script>

<body onload=rav()>
<form name="form">
<hr width="1366" size="5" color="yellow" align="left">
<marquee><h1><Font color="RoyalBlue">KALKULATOR SEDERHANA MENGGUNAKAN "JAVA SCRIPT"</h1></hr></marquee>
<hr width="1366" size="5" color="Green" align="left"/>
Masukkan nilai pertama :<br>
<input type="text" name="x"><br>
Masukkan nilai kedua :<br>
<input type="text" name="y"><br>
Pilih Salah Satu Operasi Matematika :<br><br>
<input type="button" value="  +  " onClick="penjumlahan()">
<input type="button" value="  -  " onClick="pengurangan()">
<input type="button" value="  x  " onClick="perkalian()">
<input type="button" value="  :  " onClick="pembagian()">
<input type="button" value="  ^  " onClick="pangkatdua()"><br><br>
Hasil :<br>
<input type "text" name="hasil" disabled="true"><br><br>
<input type="button" value="C" onClick="rav()">
<hr width="1366" size="9" color="Red" align="left"/>
</form>
</body>
</html>

Tidak ada komentar:

Posting Komentar