网页简易四则运算器

下载地址: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).

适用场景:

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

运行截图

网页简易四则运算器网页简易四则运算器

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

网页简易四则运算器网页简易四则运算器

上一篇:卡常技巧


下一篇:解决使用#include setupapi.h报出错误的问题