Programalama > JAVA SCRIPT

Etiketler: hesap, makinasi......

Ort. 0
Puan ver:
<HTML>
<TITLE>Hesap Makinesi</TITLE>
<style type="text/css">
<!--
@import "quiz.css";
-->
</style>

<BODY BGCOLOR=FFFFFF>
<form action="" Name="Keypad">
  <script language="VBScript">
<!--
' Module-level variables
Dim Accum		' Previous number (operand) awaiting operation
Dim FlagNewNum		' Flag to indicate a new number (operand) is being entered
Dim PendingOp		' Pending operation waiting for completion of second operand

Sub NumPressed(Byval Num)
	If FlagNewNum Then
   		Document.Keypad.Readout.Value  = Num
   		FlagNewNum = False
	Else
		If Document.Keypad.Readout.Value = "0" Then
			Document.Keypad.Readout.Value = CStr(Num)
		Else
			Document.Keypad.ReadOut.Value= Document.Keypad.ReadOut.Value & CStr(Num)
		End If
	End If
End Sub

Sub Decimal_onClick()
Dim curReadout
	curReadOut = Document.Keypad.ReadOut.Value
	If FlagNewNum Then
		curReadOut = "0."
		FlagNewNum = False
	Else
		If InStr(curReadOut, ".") = 0 Then
			curReadOut = curReadOut & "."
		End If
	End If
	Document.Keypad.ReadOut.Value = curReadOut
End Sub

Sub Plus_onClick()
	Operation "+"
End Sub

Sub Minus_onClick()
	Operation "-"
End Sub

Sub Multiply_onClick()
	Operation "*"
End Sub

Sub Divide_OnClick()
	Operation "/"
End Sub

Sub Operation(Byval Op)
Dim Readout
	ReadOut = Document.Keypad.ReadOut.Value
	If FlagNewNum and PendingOp <> "=" Then
		' User is hitting op keys repeatedly, so don't do anything
	Else
		FlagNewNum = True
		Select Case PendingOp
		Case "+"
			Accum = CDbl(Accum) + CDbl(ReadOut)
		Case "-"
			Accum = CDbl(Accum) - CDbl(ReadOut)
		Case "/"
			Accum = CDbl(Accum) / CDbl(ReadOut)
		Case "*"
			Accum = CDbl(Accum) * CDbl(ReadOut)
		Case Else
			Accum = ReadOut
		End Select
		Document.Keypad.ReadOut.Value = Accum
		PendingOp = Op
	End If
End Sub

Sub ClearEntry_onClick()
' Remove current number and reset state
    Document.Keypad.ReadOut.Value = "0"
    FlagNewNum = True
End Sub

Sub Clear_onClick()
' Clear accumulator and pending operation, and clear display
 	Accum = 0
 	PendingOp = ""
	ClearEntry_onClick
End Sub

Sub Neg_onClick()
	Document.Keypad.ReadOut.Value = CDbl(Document.Keypad.ReadOut.Value) * -1
End Sub

Sub Percent_onClick()
	Document.Keypad.ReadOut.Value = (CDbl(Document.Keypad.ReadOut.Value) / 100) * Accum
End Sub

Sub Equals_OnClick()
	Operation "="
End Sub
-->
</script>
  <table width="250" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#000000">
    <tr>
      <td bgcolor="#000000" align="left" valign="middle">
        <table border=0 cellpadding=1 cellspacing=5 align="center" bgcolor="#3399CC" width=250>
          <caption align=top><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Hesap
          Makinesi</b></font></caption>
          <tr>
            <td colspan=7 align=center valign="middle">
              <input name="ReadOut" type="Text" size=20 value="0" width=100% maxlength="20">
            </td>
          </tr>
          <tr align="left" valign="middle">
            <td>
              <input name="Clear" type="Button" value="  C   " >
            </td>
            <td></td>
            <td align="right">
              <input name="Seven" type="Button" value="  7  " onClick="NumPressed(7)">
            </td>
            <td align="center">
              <input name="Eight" type="Button" value="  8  " onClick="NumPressed(8)">
            </td>
            <td>
              <input name="Nine" type="Button" value="  9  " onClick="NumPressed(9)">
            </td>
            <td></td>
            <td align="right">
              <input name="Minus" type="Button" value="  -   " >
            </td>
          </tr>
          <tr align="left" valign="middle">
            <td>
              <input name="Percent" type="Button" value="  %  " >
            </td>
            <td></td>
            <td align="right">
              <input name="Four" type="Button" value="  4  " onClick="NumPressed(4)">
            </td>
            <td align="center">
              <input name="Five" type="Button" value="  5  " onClick="NumPressed(5)">
            </td>
            <td>
              <input name="Six" type="Button" value="  6  " onClick="NumPressed(6)">
            </td>
            <td></td>
            <td align="right">
              <input name="Divide" type="Button" value="  /   " >
            </td>
          </tr>
          <tr align="left" valign="middle">
            <td>
              <input name="Neg" type="Button" value=" +/-  " >
            </td>
            <td></td>
            <td align="right">
              <input name="One" type="Button" value="  1  " onClick="NumPressed(1)">
            </td>
            <td align="center">
              <input name="Two" type="Button" value="  2  " onClick="NumPressed(2)">
            </td>
            <td>
              <input name="Three" type="Button" value="  3  " onClick="NumPressed(3)">
            </td>
            <td></td>
            <td align="right">
              <input name="Multiply" type="Button" value="  x  " >
            </td>
          </tr>
          <tr align="left" valign="middle">
            <td>
              <input name="ClearEntry" type="Button" value=" CE " >
            </td>
            <td></td>
            <td align="right">
              <input name="Zero" type="Button" value="  0  " onClick="NumPressed(0)">
            </td>
            <td align="center">
              <input name="Decimal" type="Button" value="   ,   " >
            </td>
            <td colspan="2">
              <input name="Equals" type="Button" value="       =">
            </td>
            <td align="right">
              <input name="Plus" type="Button" value="  +  " >
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  </FORM>
<br>
<br>
<br>
</html>


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.