求一个简单js计算器要求带上注释

一个人ღ 2024-11-29 06:35:13
最佳回答
t;<title></title><style type="text/css">p .red .redl.blue </style><script language="j**ascript">var memory = 0;var number1 = "";var number2 = "";var newnumber = "blank";var opvalue = "";function d**play(d**playnumber) {document.calculator.answer.value = d**playnumber;}function memoryclear() {memory = 0;document.calculator.mem.value = "";}function memoryrecall(answer) {if(newnumber != "blank") {number2 += answer;} else {number1 = answer;}newnumber = "blank";d**play(answer);}function memorysubtract(answer) {memory = memory - eval(answer);}function memoryadd(answer) {memory = memory + eval(answer);document.calculator.mem.value = " m ";newnumber = "blank";}function clearcalc() {number1 = "";number2 = "";newnumber = "blank";d**play("");}function backspace(answer) {answerlength = answer.length;answer = answer.substring(0, answerlength - 1);if (number2 != "") {number2 = answer.tostring();d**play(number2);} else {number1 = answer.tostring();d**play(number1);}}function cecalc() {number2 = "";newnumber = "yes";d**play("");}function checknumber(answer) {if(answer == ".") {number = document.calculator.answer.value;if(number.indexof(".") != -1) {answer = "";}}if(newnumber == "yes") {number2 += answer;d**play(number2);}else {if(newnumber == "blank") {number1 = answer;number2 = "";newnumber = "no";}else {number1 += answer;}d**play(number1);}}function addbutton(x) {if(x == 1) equalbutton();if(number2 != "") {number1 = parsefloat(number1) + parsefloat(number2);}newnumber = "yes";opvalue = '+';d**play(number1);}function subbutton(x) {if(x == 1) equalbutton();if(number2 != "") {number1 = parsefloat(number1) - parsefloat(number2);}newnumber = "yes";opvalue = '-';d**play(number1);}function multbutton(x) {if(x == 1) equalbutton();if(number2 != "") {number1 = parsefloat(number1) * parsefloat(number2);}newnumber = "yes";opvalue = '*';d**play(number1);}function divbutton(x) {if(x == 1) equalbutton();if(number2 != "") {number1 = parsefloat(number1) / parsefloat(number2);}newnumber = "yes";opvalue = '/';d**play(number1);}function sqrtbutton() {number1 = math.sqrt(number1);newnumber = "blank";d**play(number1);}function percentbutton() {if(newnumber != "blank") {number2 *= .01;newnumber = "blank";d**play(number2);}}function recipbutton() {number1 = 1/number1;newnumber = "blank";d**play(number1);}function negatebutton() {number1 = parsefloat(-number1);newnumber = "no";d**play(number1);}function equalbutton() {if(opvalue == '+') addbutton(0);if(opvalue == '-') subbutton(0);if(opvalue == '*') multbutton(0);if(opvalue == '/') divbutton(0);number2 = "";opvalue = "";}</script></head><body><center><form name="calculator"><table bgcolor="#aaaaaa" width=230><tr><td><table bgcolor="#cccccc" border=1><tr><td><table border=0 cellpadding=0><tr><td bgcolor="#000080"></td></tr><tr><td><table width="100%" border=0><tr><td colspan=6><input type="text" readonly name="answer" size=30 maxlength=30 onchange="checknumber(th**.value)"></td></tr><tr><td colspan=6><table border=0 cellpadding=0><tr><td><input type="text" name="mem" size=3 maxlength=3 readonly style="background:menu"> <input type="button" name="backspace" class="redl" value="退格" onclick="backspace(document.calculator.answer.value); return false;"> <input type="button" name="ce" class="redl" value="ce" onclick="cecalc(); return false;"> <input type="reset" name="c" class="redl" value="c" onclick="clearcalc(); return false;"></td></tr></table></td></tr><tr><td><input type="button" name="mc" class="red" value=" mc " onclick="memoryclear(); return false;"></td><td><input type="button" name="calc7" class="blue" value=" 7 " onclick="checknumber('7'); return false;"></td><td><input type="button" name="calc8" class="blue" value=" 8 " onclick="checknumber('8'); return false;"></td><td><input type="button" name="calc9" class="blue" value=" 9 " onclick="checknumber('9'); return false;"></td><td><input type="button" name="divide" class="red" value=" / " onclick="divbutton(1); return false;"></td><td><input type="button" name="sqrt" class="blue" value="sqrt" onclick="sqrtbutton(); return false;"></td></tr><tr><td><input type="button" name="mr" class="red" value=" mr " onclick="memoryrecall(memory); return false;"></td><td><input type="button" name="calc4" class="blue" value=" 4 " onclick="checknumber('4'); return false;"></td><td><input type="button" name="calc5" class="blue" value=" 5 " onclick="checknumber('5'); return false;"></td><td><input type="button" name="calc6" class="blue" value=" 6 " onclick="checknumber('6'); return false;"></td><td><input type="button" name="multiply" class="red" value=" * " onclick="multbutton(1); return false;"></td><td><input type="button" name="percent" class="blue" value=" % " onclick="percentbutton(); return false;"></td></tr><tr><td><input type="button" name="ms" class="red" value=" ms " onclick="memorysubtract(document.calculator.answer.value); return false;"></td><td><input type="button" name="calc1" class="blue" value=" 1 " onclick="checknumber('1'); return false;"></td><td><input type="button" name="calc2" class="blue" value=" 2 " onclick="checknumber('2'); return false;"></td><td><input type="button" name="calc3" class="blue" value=" 3 " onclick="checknumber('3'); return false;"></td><td><input type="button" name="minus" class="red" value=" - " onclick="subbutton(1); return false;"></td><td><input type="button" name="recip" class="blue" value="1/x " onclick="recipbutton(); return false;"></td></tr><tr><td><input type="button" name="mplus" class="red" value=" m+ " onclick="memoryadd(document.calculator.answer.value); return false;"></td><td><input type="button" name="calc0" class="blue" value=" 0 " onclick="checknumber('0'); return false;"></td><td><input type="button" name="negate" class="blue" value="+/- " onclick="negatebutton(); return false;"></td><td><input type="button" name="dot" class="blue" value=" . " onclick="checknumber('.'); return false;"></td><td><input type="button" name="plus" class="red" value=" + " onclick="addbutton(1); return false;"></td><td><input type="button" name="equal" class="red" value=" = " onclick="equalbutton(); return false;"></td></tr></table></td></tr></table></td></tr></table></td></tr></table></form></center><script language=j**ascript>function keydown(){var icode=window.event.keycode;//alert(icode);if(event.shiftkey){switch(icode){case 56:document.all.multiply.click();break;case 59:document.all.minus.click();break;case 60:document.all.plus.click();break;}}if(!event.shiftkey&&!event.ctrlkey&&!event.altkey){switch (icode){case 8:document.all.backspace.click();break;case 187:document.all.equal.click();break;case 96:document.all.calc0.click();break;case 97:document.all.calc1.click();break;case 98:document.all.calc2.click();break;case 99:document.all.calc3.click();break;case 100:document.all.calc4.click();break;case 101:document.all.calc5.click();break;case 102:document.all.calc6.click();break;case 103:document.all.calc7.click();break;case 104:document.all.calc8.click();break;case 105:document.all.calc9.click();break;case 110:document.all.dot.click();break;case 13:document.all.equal.click();break;case 107:document.all.plus.click();break;case 109:document.all.minus.click();break;case 106:document.all.multiply.click();break;case 111:document.all.divide.click();break;case 48:document.all.calc0.click();break;case 49:document.all.calc1.click();break;case 50:document.all.calc2.click();break;case 51:document.all.calc3.click();break;case 52:document.all.calc4.click();break;case 53:document.all.calc5.click();break;case 54:document.all.calc6.click();break;case 55:document.all.calc7.click();break;case 56:document.all.calc8.click();break;case 57:document.all.calc9.click();break;case 190:document.all.dot.click();break;case 13:document.all.equal.click();break;case 191:document.all.divide.click();break;}}//event.keycode=0;//event.returnvalue=false;}window.document.attachevent("onkeydown",keydown)</script></body></html>这是当时我学生做的一个,分拿来....完全符合你的要求. 20210311
汇率兑换计算器

类似问答
  • 求帮忙做一个简单的mt4指标
    • 2024-11-29 23:32:24
    • 提问者: 未知
    stickline(close>ref(close,1) ,low,high,0,0),colorred;stickline(close>ref(close,1) ,close,close,6,0),colorred;stickline(close<=ref(close,1) ,low,high,0,0),colorblue;stickline(close<=ref(...
  • 求一份会计个人简历
    • 2024-11-29 03:13:17
    • 提问者: 未知
    人简历的写法及意的问题  个人简历  个人简历可以是表格的形式,也可以是其他形式。个人简历一般应包括以下几个方面的内容:  (1)个人资料:姓名、性别、出生年月、家庭地址、**面貌、婚姻状况,身体状况,兴趣、爱好、性格等等;  (2)学业有关内容:就读学校、所学专业、学位、外语及计算机掌握程度等等;  (3)本人经历:入学以来的简单经历,主要是担任社会工作或加入党团等方面的情况;  (4)所获荣誉...
  • 求一个可以计算房贷款18年的提前还款计算器!
    • 2024-11-29 20:47:29
    • 提问者: 未知
    给您一个表格,上面商贷、住宅、公积金都能算出来,公式:贷款金额等额本息=月供
  • 求长沙银行房贷计算器
    • 2024-11-29 20:29:44
    • 提问者: 未知
    您好,你可以去百度上搜一下,就可以了,上面只要你把你的条件输进去就出来答案了!
  • 用html和js编程,实现一个简单的计算器
    • 2024-11-29 19:00:45
    • 提问者: 未知
    var r = math.pow(1.1,2);console.log(r.tofixed(2));
  • 求推荐一款计算器app?
    • 2024-11-29 11:47:02
    • 提问者: 未知
    myscript calculator-手写计算器 你下载后会回来点赞的 算你狠全能计算器,名字很想吐槽,但是确实超好用(。・ω・。)ノ♡,我是算实验数据用的。它可以看到之前的计算记录...
  • 怎样用科学计算器求角度
    • 2024-11-29 12:05:37
    • 提问者: 未知
    frm考试 用计算器 高顿财经frm考过人分享frm备考经验-高顿frm金融行 frm.gaodun.com casio 科学计算器-京东,网上购物的首选,商品质优价优!买casio 科学计算器-选京东,全新...
  • baii计算器怎么求下面这个数?
    • 2024-11-29 22:30:15
    • 提问者: 未知
    0.98*(1+ear)^40/365=1 求ear
  • mac上有没有好用的科学计算器,求推荐一款!
    • 2024-11-29 05:50:34
    • 提问者: 未知
    适用于mac系统好用的计算器软件可以试试soulver,界面简洁,简单实用。soulver比电子表格更聪明,比传统计算器更清晰。只需输入问题soulver就能迅速计算给出答案。此外,计算速度极快还可以解方程,是程序员们必备的计算软件。mac金币 以上就是【mac金币】为您提供的回答,希望对你有所帮助!...
  • 求大神算一下这个单利复利的计算题
    • 2024-11-29 05:28:55
    • 提问者: 未知
    a的利息=500x6%x3=90(万元)b的利息=500x(1+5.8%)³-500=92.14(万元)答:向a银行借款利息较低。求采纳,谢谢!
汇率兑换计算器

热门推荐
热门问答
最新问答
推荐问答
新手帮助
常见问题
房贷计算器-九子财经 | 备案号: 桂ICP备19010581号-1 商务联系 企鹅:2790-680461

特别声明:本网为公益网站,人人都可发布,所有内容为会员自行上传发布",本站不承担任何法律责任,如内容有该作者著作权或违规内容,请联系我们清空删除。