Ir para conteúdo

Calculadora Em Java


GM Netox

Posts Recomendados

Pode ser usado desde em sites com agenda eletronica até sites de compras usados para calcular o frete

 

EIS O CODIGO FONTE

 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Nova pagina 1</title>
<STYLE> <!-- .estilo1{color:Black;text-decoration:none;font-size:12px;font-family:Arial}a:hover{text-decoration:underline;}--> </STYLE><title>// PLUGMasters.com.br</title>
</head>
<body bgcolor=#FFFFFF> <blockquote> <center>
  <table width=468 border=0 cellspacing=0 align=center cellpadding=2>
 <tr>
   <td height=2><div align="center">
	   <!-- -->
	   <script language='JavaScript' type='text/javascript'>
<!--
 if (!document.phpAds_used) document.phpAds_used = ',';
 phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

 document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
 document.write ("&what=zone:1&target=_blank");
 document.write ("&exclude=" + document.phpAds_used);
 if (document.referer)
 document.write ("&referer=" + escape(document.referer));
 document.write ("'><" + "/script>");
//-->
 </script>
	   <noscript>
				   </noscript>
	   <!-- -->
   </div></td>
 </tr>
  </table>
  <h1><font face="Verdana, Arial, Helvetica, sans-serif" size=2><b>Calculadora</b></font><b><font face="Verdana, Arial, Helvetica" size=2> </font></b></h1> <form name=Keypad> <table> <table border=2 width=50 height=60 cellpadding=1 cellspacing=5><tr><td colspan=3 align=middle> <input name=ReadOut type=Text size=24 value=0 width=100%></td><td ></td><td> <input name=btnClear type=Button value="  C  " onClick=Clear()></td><td> <input name=btnClearEntry type=Button value="  CE " onClick=ClearEntry()></td></tr><tr><td> <input name=btnSeven type=Button value="  7  " onClick=NumPressed(7)></td><td> <input name=btnEight type=Button value="  8  " onClick=NumPressed(8)></td><td> <input name=btnNine type=Button value="  9  " onClick=NumPressed(9)></td><td></td><td> <input name=btnNeg type=Button value=" +/- " onClick=Neg()></td><td> <input name=btnPercent type=Button value="  % " onClick=Percent()></td></tr><tr><td> <input name=btnFour type=Button value="  4  " onClick=NumPressed(4)></td><td> <input name=btnFive type=Button value="  5  " onClick=NumPressed(5)></td><td> <input name=btnSix type=Button value="  6  " onClick=NumPressed(6)></td><td></td><td align=middle> <input name=btnPlus type=Button value="  +  " onClick="Operation('+')"></td><td align=middle> <input name=btnMinus type=Button value="   -   " onClick="Operation('-')"></td></tr><tr><td> <input name=btnOne type=Button value="  1  " onClick=NumPressed(1)></td><td> <input name=btnTwo type=Button value="  2  " onClick=NumPressed(2)></td><td> <input name=btnThree type=Button value="  3  " onClick=NumPressed(3)></td><td></td><td align=middle> <input name=btnMultiply type=Button value="  *  " onClick="Operation('*')"></td><td align=middle> <input name=btnDivide type=Button value="   /   " onClick="Operation('/')"></td></tr><tr><td> <input name=btnZero type=Button value="  0  " onClick=NumPressed(0)></td><td> <input name=btnDecimal type=Button value="   .  " onClick=Decimal()></td><td colspan=3></td><td> <input name=btnEquals type=Button value="  =  " onClick="Operation('=')"></td></tr> </table> </table> </form><p><font face="Verdana, Arial, Helvetica" size=2> <script language=JavaScript>
<!-- Begin
var FKeyPad = document.Keypad;
var Accumulate = 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 )
Accumulate += parseFloat(Readout);
else if ( '-' == PendingOp )
Accumulate -= parseFloat(Readout);
else if ( '/' == PendingOp )
Accumulate /= parseFloat(Readout);
else if ( '*' == PendingOp )
Accumulate *= parseFloat(Readout);
else
Accumulate = parseFloat(Readout);
FKeyPad.ReadOut.value = Accumulate;
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 () {
Accumulate = 0;
PendingOp = "";
ClearEntry();
}
function Neg () {
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Percent () {
FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accumulate);
}
//-->
</script> </font></p><p> </p>
  <p> 
  
  </p>
  <div align=center> </div>
  <p><font face=Verdana size=1 color=#000000> </font><font face=Verdana size=1 color=#000000> </font></p> </center> </blockquote> <div align=center> </div></body></html>

--

Créditos:

Igor Escobar

--

Abraços

Link para o comentário
Compartilhar em outros sites

  • 7 months later...
×
×
  • Criar Novo...