ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

网页简易四则运算器

2021-05-18 22:35:40  阅读:227  来源: 互联网

标签:functions 四则运算 网页 button Javascript 简易 values output input


下载地址:https://download.csdn.net/download/qq_31293575/18340399

项目介绍

Calculator Website

The George Washington University

Computer Science 1023

Professor Brenner (nbrenner@gwu.edu)

 

Build a website to simulate a simple four function calculator.  Include two input boxes and one output textbox. On a button click, perform the arithmetic calculation and update the output box.  Include an error message if division by 0 is attempted.   Here is a sample webpage:

 

 

 

Appearance of the calculator just after the multiply button was clicked

 

 

Hints on constructing the program:

 

  1. First build the HTML with all the features shown in the sample.
  2. Add the onclick option to each button to go to a different Javascript function (so four Javascript functions must be written).
  3. Write and debug (using alert() pop-ups) the code for one of the arithmetic functions, say multiply.
  4. Only when that one button is working correctly should you copy its code, paste it into the other functions and make the appropriate (and very minor) changes.
  5. In each button function, first read in the input values that the user inserted; e.g. x = textboxname.value and similarly for y for the two input values.
  6. Perform the appropriate arithmetic operation. (NOTE: when performing addition, beware of the Javascript ambiguity regarding the plus sign; either use subtraction twice or else multiply the input values (which are strings) by 1 to convert them to numbers.)
  7. Place the numeric result into the output box by the converse of the way you copied in the input values.
  8. If you have trouble comparing to 0, try comparing to “0”
  9. Turn on the error console for the browser (F12 usually) you are using so that you will see any error messages from Javascript (in the Console).

适用场景:

毕业论文、课程设计、公司项目参考

运行截图

关注【程序代做 源码分享】公众号获取更多免费源码!!!

标签:functions,四则运算,网页,button,Javascript,简易,values,output,input
来源: https://www.cnblogs.com/daizuo/p/14782961.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有