Membuat Kalkulator dengan Notepad 2



Setelah Memposting Cara Membuat Kalkulator dengan Notepad, sekarang saya memposting Bagian Keduanya. Bagian pertama menggunakan bahasa pemrograman Batch, sedangkan bagian kedua menggunakan bahasa pemrograman HTML. Simple saja, siapkan Notepad atau Notepad++. Jangan lupa languagenya HTML(khusus yang ++).

Baca, dan Lakukan dengan Sabar!

  • Pastekan kode dibawah ini di Notepad atau Notepad++ :
    <html>
    <head>
    <title>HTML Kalkulator</title>
    </head>
    <body>
    <form name="Keypad" action>
    <table border="1"&nbsp; 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="&nbsp; 7&nbsp; " onClick="NumPressed(7)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnEight" type="Button" value="&nbsp; 8&nbsp; " onClick="NumPressed(8)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnNine" type="Button" value="&nbsp; 9&nbsp; " 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="&nbsp; 4&nbsp; " onClick="NumPressed(4)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnFive" type="Button" value="&nbsp; 5&nbsp; " onClick="NumPressed(5)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnSix" type="Button" value="&nbsp; 6&nbsp; " onClick="NumPressed(6)">
    </td>
    <td bgcolor="#DFDFDF"><input name="btnPlus" type="Button" value="&nbsp; +&nbsp; "
    onClick="Operation('+')"></td>
    <td bgcolor="#DFDFDF"><input name="btnMultiply" type="Button" value="&nbsp; *&nbsp; "
    onClick="Operation('*')"></td>

    </tr>
    <tr>
    <td bgcolor="#DFDFDF">
    <input name="btnOne" type="Button" value="&nbsp; 1&nbsp; " onClick="NumPressed(1)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnTwo" type="Button" value="&nbsp; 2&nbsp; " onClick="NumPressed(2)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnThree" type="Button" value="&nbsp; 3&nbsp; " onClick="NumPressed(3)">
    </td>
    <td bgcolor="#DFDFDF"><input name="btnMinus" type="Button" value="&nbsp; -&nbsp; "
    onClick="Operation('-')"></td>
    <td bgcolor="#DFDFDF"><input name="btnDivide" type="Button" value="&nbsp; /&nbsp; "
    onClick="Operation('/')"></td>

    </tr>
    <tr>
    <td bgcolor="#DFDFDF">
    <input name="btnZero" type="Button" value="&nbsp; 0&nbsp; " onClick="NumPressed(0)">
    </td>
    <td bgcolor="#DFDFDF">
    <input name="btnDecimal" type="Button" value="&nbsp; .&nbsp; " onClick="Decimal()">
    </td>
    <td colspan="3"&nbsp; bgcolor="#797979">
    <input name="btnClear" type="Button" value="&nbsp; C&nbsp; " onClick="Clear()">
    <input name="btnClearEntry" type="Button" value=" CE " onClick="ClearEntry()">
    <input name="btnEquals" type="Button" value="&nbsp; =&nbsp; " 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>
    </body>
    </html>
  • Simpan dengan Nama Kalkulator2.html
  • Tes dulu kalkulator anda.
Semoga Bermanfaat.


Komentar

2 Komentar di artikel "Membuat Kalkulator dengan Notepad 2"

Admin mengatakan...

nice post, coba ah. . .

need suport: www.mainpedia.blogspot.com


15 Oktober 2011 pukul 07.46
Ariq-XP Creativity mengatakan...

@ Mainpedia

siip, ke TKP


3 November 2011 pukul 00.10

Posting Komentar

Blog ini blog DOFOLLOW, jadi dapatkan backlink gratis hanya dengan berkomentar.

Recent Post

Popular Posts

Return to top of page Copyright © 2011-2012 | Ariq-XP Blog | Platinum Theme Converted into Blogger Template by Hack Tutors