下载地址: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:
- First build the HTML with all the features shown in the sample.
- Add the onclick option to each button to go to a different Javascript function (so four Javascript functions must be written).
- Write and debug (using alert() pop-ups) the code for one of the arithmetic functions, say multiply.
- 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.
- 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.
- 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.)
- Place the numeric result into the output box by the converse of the way you copied in the input values.
- If you have trouble comparing to 0, try comparing to “0”
- 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).
适用场景:
毕业论文、课程设计、公司项目参考
运行截图
关注【程序代做 源码分享】公众号获取更多免费源码!!!