Admin المدير العام
عدد الرسائل : 96 الموقع : www.csc1.yoo7.com بدايتك بالانترنت : 2004 ما هو نظام جهازك : Windows xp تاريخ التسجيل : 12/05/2008
| موضوع: كود جافا آلة حاسبة الإثنين 12 يناير 2009, 10:03 pm | |
| كود جافا آلة حاسبة - الكود:
-
<form name=mef> <input type=hidden name=dafunction value=""> <input type=hidden name=tempnum value=""> <input type=hidden name=daboo value=""> <input type=hidden name=memob value="0"> <script language=javascript> function numbers(x) { var daboo= dcidcidocument.mef.daboo.value; var dafunction = dcidcidocument.mef.dafunction.value; var deccheck = dcidcidocument.mef.results.value; if(dcidcidocument.mef.results.value == "0" && deccheck.indexOf('.')=="-1") { dcidcidocument.mef.results.value = ""; } if(daboo != "true") { dcidcidocument.mef.results.value=dcidcidocument.mef.results.value+x; } else { dcidcidocument.mef.results.value=x; dcidcidocument.mef.daboo.value=""; } } function add() { if(dcidcidocument.mef.tempnum.value){ gofigure(); } dcidcidocument.mef.dafunction.value='+'; dcidcidocument.mef.daboo.value='true'; dcidcidocument.mef.tempnum.value=dcidcidocument.mef.results.value; } function subtract() { if(dcidcidocument.mef.tempnum.value){ gofigure(); } dcidcidocument.mef.dafunction.value='-'; dcidcidocument.mef.daboo.value='true'; dcidcidocument.mef.tempnum.value=dcidcidocument.mef.results.value; } function multiply() { if(dcidcidocument.mef.tempnum.value){ gofigure(); } dcidcidocument.mef.dafunction.value='*'; dcidcidocument.mef.daboo.value='true'; dcidcidocument.mef.tempnum.value=dcidcidocument.mef.results.value; } function divide() { if(dcidcidocument.mef.tempnum.value){ gofigure(); } dcidcidocument.mef.dafunction.value='/'; dcidcidocument.mef.daboo.value='true'; dcidcidocument.mef.tempnum.value=dcidcidocument.mef.results.value; } function oneoverx() { dcidcidocument.mef.results.value=1/eval(dcidcidocument.mef.results.value); } function percenta() { var whatdo = dcidcidocument.mef.dafunction.value; var percnumber = dcidcidocument.mef.results.value / 100; if(dcidcidocument.mef.tempnum.value){ dcidcidocument.mef.results.value = eval(dcidcidocument.mef.tempnum.value)*percnumber; } else { dcidcidocument.mef.results.value = "0"; } dcidcidocument.mef.tempnum.value=""; dcidcidocument.mef.dafunction.value=""; } function squaroot() { dcidcidocument.mef.results.value=Math.sqrt(dcidcidocument.mef.results.value); } function plusminus() { var xy = dcidcidocument.mef.results.value; if(xy == "0"){ return false; } if(xy.indexOf("-") == "0") { xy = xy.substring(1,xy.length); } else { xy = "-" + xy; } dcidcidocument.mef.results.value = xy; } function backspace() { //ignore if zero already.// if(dcidcidocument.mef.results.value=="0") { return false; } //length of the text field// var numlength = dcidcidocument.mef.results.value; //subtract one.// var newresult = numlength.length-1; //set to new value -1;// dcidcidocument.mef.results.value = numlength.substring(0,newresult); //set to zero if nothing left. if(dcidcidocument.mef.results.value=="") {dcidcidocument.mef.results.value ="0";} } function clearfu() { dcidcidocument.mef.tempnum.value=""; dcidcidocument.mef.results.value="0"; dcidcidocument.mef.dafunction.value=""; } function gofigure() { if(dcidcidocument.mef.tempnum.value==".") { return false; } var whatdo = dcidcidocument.mef.dafunction.value; if(whatdo=="+"){ dcidcidocument.mef.results.value = eval(dcidcidocument.mef.results.value) + eval(dcidcidocument.mef.tempnum.value); } else if(whatdo=="-"){ dcidcidocument.mef.results.value = eval(dcidcidocument.mef.tempnum.value)-eval(dcidcidocument.mef.results.value); } else if(whatdo=="*"){ dcidcidocument.mef.results.value = eval(dcidcidocument.mef.results.value) * eval(dcidcidocument.mef.tempnum.value); } else if(whatdo=="/"){ dcidcidocument.mef.results.value = eval(dcidcidocument.mef.tempnum.value)/eval(dcidcidocument.mef.results.value) ; } dcidcidocument.mef.tempnum.value=""; dcidcidocument.mef.dafunction.value=""; } </script> <script language=javascript> <!--// if (navigator.appName == "Netscape") { dcidcidocument.write("<h3 align=center>Looks Like you're using netscape. Because Netscape is a lousy browser and doesn't do a very good job with CSS the below looks aweful. Please Use Internet Explorer and Not the buggy netscape navigotor.</h3>"); } //--> </script> <table style="border-style:inset;border-width:2px;" bgcolor=#3399ff><tr> <td> <p align="center"><span lang="ar-sa"><b><font face="verdana" color="#FFFFFF">آلة حاسبة</font></b></span></td></tr><tr> <td><input type=text value="0" size=33 name=results></td> </tr> <tr><td> <input type=text name=memry style="background-color:#cccccc;" size=2> <input type=button value="Backspace" style="background-color:#CCCCCC;color:red;width:67px;height:27px;font-size:10px;" OnClick="backspace()"> <input type=button value=" CE " style="background-color:#CCCCCC;color:red;width:67px;height:27px;font-size:10px;" OnClick="clearfu()"> <input type=button value=" C " style="background-color:#CCCCCC;color:red;width:57px;height:27px;font-size:10px;" OnClick="clearfu()"> </td></tr><tr> <td> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" MC " OnClick="dcidcidocument.mef.memry.value=' ',dcidcidocument.mef.memob.value='0'"> <input type=button value=" 7 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(7)"> <input type=button value=" 8 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(8)"> <input type=button value=" 9 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(9)"> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" / " OnClick="divide()"> <input type=button style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" value="sqrt" OnClick="squaroot()"> </td></tr><tr> <td> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value="MR" OnClick="dcidcidocument.mef.results.value=dcidcidocument.mef.memob.value"> <input type=button value=" 4 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(4)"> <input type=button value=" 5 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(5)"> <input type=button value=" 6 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(6)"> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" * " OnClick="multiply()"> <input type=button style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" value=" % " OnClick="percenta()"> </td></tr> <tr> <td> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" MS "> <input type=button value=" 1 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(1)"> <input type=button value=" 2 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(2)"> <input type=button value=" 3 " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(3)"> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" - " OnClick="subtract()"> <input type=button style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" value=" 1/x " OnClick="oneoverx()"> </td> </tr><tr> <td> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" M+ " OnClick="dcidcidocument.mef.memry.value=' M',dcidcidocument.mef.memob.value=dcidcidocument.mef.results.value;"> <input type=button value="0" style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers(0)"> <input type=button value="+/-" style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="plusminus() "> <input type=button value=" . " style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" OnClick="numbers('.')"> <input type=button style="background-color:#CCCCCC;color:red;width:35px;height:27px;font-size:10px;" value=" + " OnClick="add()"> <input type=button style="background-color:#CCCCCC;color:blue;width:35px;height:27px;font-size:10px;" value=" = " OnClick="gofigure()"> </td></tr> <tr><td> </td></tr> </table> | |
|