Membuat Kalkulator
Pada postingan kali ini, sebenarnya hanya mempublikasikan tugas yang diberikan salah satu dosen saya . . .
Sebenarnya, tidak perlu diposting, cukup dikumpulkan saja,,,tetapi 
alangkah baiknya juga saya posting di blogger saya ini,,,
alhamdulillah, jika ada juga orang lain mencari berupa tugas ini ,,,
berbagi ilmu dan juga kebaikan...
wahhh,,,ada juga sih yang agak gagal,,tapi gak pa2....perbaiki sendiri ya,,,
gue (sok gaul) juga copy paste,,,,hehehe
kan ada mbah google...sayangkan gak dimanfaatkan . . . . .. 
wahhhhh,,,,,,gak usah panjang lebar ya sama dengan luas persegi panjang...
aheheheee,,,, bercanda.....
ini langsung aja beberapa syntax untuk kalkultaor
1. pertama-tama buka terlebih dahulu notepad anda dan ketik (copy & paste) pada tulisan di bawah ini
2. simpan dengan memberikan nama yang anda inginkan
3. pahami isinya,,mungkin ada kegagalan
4. selesai
===========================================================

<html>
<title>Kalkulator</title>
<body bgcolor="tan">
<center>
<img src="khavis3.jpg" width="345" height="150" alt="Khavis3" usemap="#myimagemap"/>  <img src="khavis8.jpg" width="250" height="150" alt="Khavis8" usemap="#myimagemap"/> <img src="khavis4.jpg" width="175" height="150" alt="Khavis4" usemap="#myimagemap"/>  <img src="unpar.png" width="175" height="150" alt="unpar" usemap="#myimagemap"/> <img src="khavis2.jpg" width="175" height="150" alt="khavis2" usemap="#myimagemap"/>
<p></p>
<p></p>
<font size="5">Kunjungi Blogger dan facebook Saya di alamat: www.muhammadkhavisz.blogspot.com dan www.facebook.com/khavhiedsz</font>
<p>Gunakan Software Google Chrome untuk menggunakan kalkulator-kalkulator di bawah ini</p>
<font size="5">Kalkulator 1</font>
<form name="Keypad" action>
<table border="4" bgcolor="#838383">
<tr>
<td colspan="5" bgcolor="#DFDFDF">
<input name="ReadOut" type="Text" size="30" value="0">
</td>
</tr>
<tr>
<td bgcolor="#DFDFDF">
<input name="btnSeven" type="Button" value=" 7 " onClick="NumPressed(7)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnEight" type="Button" value=" 8 " onClick="NumPressed(8)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnNine" type="Button" value=" 9 " onClick="NumPressed(9)">
</td>
<td bgcolor="#DFDFDF"><input name="btnNeg" type="Button" value=" +/- " onClick="Neg()"></td>
<td bgcolor="#DFDFDF"><input name="btnPercent" type="Button" value=" % " onClick="Percent()"></td>

</tr>
<tr>
<td bgcolor="#DFDFDF">
<input name="btnFour" type="Button" value=" 4 " onClick="NumPressed(4)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnFive" type="Button" value=" 5 " onClick="NumPressed(5)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnSix" type="Button" value=" 6 " onClick="NumPressed(6)">
</td>
<td bgcolor="#DFDFDF"><input name="btnPlus" type="Button" value=" + "
onClick="Operation('+')"></td>
<td bgcolor="#DFDFDF"><input name="btnMultiply" type="Button" value=" * "
onClick="Operation('*')"></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">
<input name="btnOne" type="Button" value=" 1 " onClick="NumPressed(1)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnTwo" type="Button" value=" 2 " onClick="NumPressed(2)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnThree" type="Button" value=" 3 " onClick="NumPressed(3)">
</td>
<td bgcolor="#DFDFDF"><input name="btnMinus" type="Button" value=" - "
onClick="Operation('-')"></td>
<td bgcolor="#DFDFDF"><input name="btnDivide" type="Button" value=" / "
onClick="Operation('/')"></td>

</tr>
<tr>
<td bgcolor="#DFDFDF">
<input name="btnZero" type="Button" value=" 0 " onClick="NumPressed(0)">
</td>
<td bgcolor="#DFDFDF">
<input name="btnDecimal" type="Button" value=" . " onClick="Decimal()">
</td>
<td colspan="3" bgcolor="#797979">
<input name="btnClear" type="Button" value=" C " onClick="Clear()">
<input name="btnClearEntry" type="Button" value=" CE " onClick="ClearEntry()">
<input name="btnEquals" type="Button" value=" = " onClick="Operation('=')"></td>
</tr>
</table>
</form>
<script LANGUAGE="JavaScript">

var FKeyPad = document.Keypad;
var Accum = 0;
var FlagNewNum = false;
var PendingOp = "";
function NumPressed (Num) {
if (FlagNewNum) {
FKeyPad.ReadOut.value = Num;
FlagNewNum = false;
}
else {
if (FKeyPad.ReadOut.value == "0")
FKeyPad.ReadOut.value = Num;
else
FKeyPad.ReadOut.value += Num;
}
}
function Operation (Op) {
var Readout = FKeyPad.ReadOut.value;
if (FlagNewNum && PendingOp != "=");
else
{
FlagNewNum = true;
if ( '+' == PendingOp )
Accum += parseFloat(Readout);
else if ( '-' == PendingOp )
Accum -= parseFloat(Readout);
else if ( '/' == PendingOp )
Accum /= parseFloat(Readout);
else if ( '*' == PendingOp )
Accum *= parseFloat(Readout);
else
Accum = parseFloat(Readout);
FKeyPad.ReadOut.value = Accum;
PendingOp = Op;
}
}
function Decimal () {
var curReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum) {
curReadOut = "0.";
FlagNewNum = false;
}
else
{
if (curReadOut.indexOf(".") == -1)
curReadOut += ".";
}
FKeyPad.ReadOut.value = curReadOut;
}
function ClearEntry () {
FKeyPad.ReadOut.value = "0";
FlagNewNum = true;
}
function Clear () {
Accum = 0;
PendingOp = "";
ClearEntry();
}
function Neg () {
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Percent () {
FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accum);
}
</script>
<br>

<font size="5">Kalkulator 2</font>
<FORM NAME="Calc">
<TABLE BORDER=4>
<TR>
<TD>
<INPUT TYPE="text" NAME="Input" Size="16">
<br>
</TD>
</TR>
<TR> <TD> <INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'"> <INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'"> <INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'"> <INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '"> <br> <INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'"> <INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'"> <INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'"> <INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '"> <br> <INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'"> <INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'"> <INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'"> <INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '"> <br> <INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''"> <INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'"> <INPUT TYPE="button" NAME="DoIt" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)"> <INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '">
<br>
</TD>
</TR>
</TABLE>
</FORM>
</center>
</body>
</html>

<html>
<title>Program Kalkulator Sederhana</title>
<SCRIPT LANGUAGE="JavaScript">
function tambah()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a+b
form.hasil.value = c
}

function kurang()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a-b
form.hasil.value=c
}

function kali()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a*b
form.hasil.value=c
}

function bagi()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a/b
form.hasil.value = c
}

function pangkat()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=Math.pow(a, b)
form.hasil.value = c
}

function kosong()
{
form.a.focus()
form.a.value=""
form.b.value=""
form.hasil.value=""

}

</SCRIPT>

<body onload=kosong()>
<CENTER>
<font size="5">Kalkulator 3</font>
<hr size="5" color="red">
<FORM name="form">
<pre>
Angka 1 <input type="text" name="a">
Angka 2 <input type="text" name="b">

Hasil <input type "text" name="hasil" disabled="true">
</pre>
<hr size="2" color="blue">
<input type="button" value=" + " onClick="tambah()">
<input type="button" value=" - " onClick="kurang()">
<input type="button" value=" x " onClick="kali()">
<input type="button" value=" / " onClick="bagi()">
<input type="button" value=" ^ " onClick="pangkat()"><br>
<input type="button" value=" Kosong " onClick="kosong()">

<br>
</FORM>

<font size="5">Kalkulator 4</font>
<form id="penjumlahan_fzb"
onsubmit="return false"
oninput="document.getElementById('hasil_penjumlahan').innerHTML = parseFloat(document.getElementById('bilangan_penjumlahan1').value) + parseFloat(document.getElementById('bilangan_penjumlahan2').value)">
<input name="bilangan_penjumlahan1" id="bilangan_penjumlahan1" type="number" value="10">
+
<input name="bilangan_penjumlahan2" id="bilangan_penjumlahan2" type="number" value="3">
=
<output name="hasil_penjumlahan" id="hasil_penjumlahan">13</output>
</form>
<form id="pengurangan_fzb"
onsubmit="return false"
oninput="document.getElementById('hasil_pengurangan').innerHTML = parseFloat(document.getElementById('bilangan_pengurangan1').value) - parseFloat(document.getElementById('bilangan_pengurangan2').value)">
<input name="bilangan_pengurangan1" id="bilangan_pengurangan1" type="number" value="23">
-
<input name="bilangan_pengurangan2" id="bilangan_pengurangan2" type="number" value="10">
=
<output name="hasil_pengurangan" id="hasil_pengurangan">13</output>
</form>
<form id="perkalian_fzb"
onsubmit="return false"
oninput="document.getElementById('hasil_perkalian').innerHTML = parseFloat(document.getElementById('bilangan_perkalian1').value) * parseFloat(document.getElementById('bilangan_perkalian2').value)">
<input name="bilangan_perkalian1" id="bilangan_perkalian1" type="number" value="13">
x
<input name="bilangan_perkalian2" id="bilangan_perkalian2" type="number" value="1">
=
<output name="hasil_perkalian" id="hasil_perkalian">13</output>
</form>
<form id="pembagian_fzb"
onsubmit="return false"
oninput="document.getElementById('hasil_pembagian').innerHTML = parseFloat(document.getElementById('bilangan_pembagian1').value) / parseFloat(document.getElementById('bilangan_pembagian2').value)">
<input name="bilangan_pembagian1" id="bilangan_pembagian1" type="number" value="26">
÷
<input name="bilangan_pembagian2" id="bilangan_pembagian2" type="number" value="2">
=
<output name="hasil_pembagian" id="hasil_pembagian">13</output>
</form>
</CENTER>

</body>

</html>
========================================================================
ini contoh hasil pada penulisan tugas saya,,,menjadi 2 gambar



Reviews:

Posting Komentar

Berbagi Ilmu © 2014 - Designed by Templateism, Distributed By Blogger Templates | Templatelib

Contact us

Diberdayakan oleh Blogger.