A simple addition, subtraction, multiplication, and Division calculator is used to copy a struts1demo modification: struts1calc
Solution 1: struts1calc create actionform:
Calcform extends actionform, num1 num2, generate getter setter;
Create four actions. On the page, use JavaScript to control the submission to different action beans.
Addaction:
public class AddAction extends Action {@Overridepublic Acti
Write a simple calculator using the C # language:The source code is as follows:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceSimple Calculator { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidButton1_Clic
= Pfun[input] (NUM1, num2); Call the array pointer function and perform the corresponding operation}else if (input = = 0)//exit Program{Exit (Exit_failure);}Else{printf ("Select Error \ n"); The selection is wrong}printf ("ret =%d\n", ret); Results of the output calculation}return 0;}In the main function while loop, you can also use the switch statement to do the corresponding operationThe code is as follows:switch (input){Case 1:ret = _add (NUM1, num2);BreakCase 2:ret = _sub (NUM1, num2);Break
operation symbol +-*/is pressed, the input value is converted into floating point storage into number1, and the input value is emptied, and the current operation symbol is stored in the Mysi;If press =, convert the input value into floating point storage into number2, and empty the input value, according to the stored Mysi operation symbol, NUMBER1, calculated;2.2Input values, real-time display of output values.2.3Finally consider clearing 0 keys, the abdication key and input and output to esta
Tag:i++trylogparse Operations als calculator indexring var calc={getdata:function (arr) {var tempstr = ""; var data = [];//formatted data for (var i = 0; i JS Simple calculator Bottom arithmetic logic
Previously released a simple calculator, today made a change, added a keyboard monitoring event, no longer use the mouse point of order
JS Code:
var Yunsuan = 0;//operation symbol, 0-no operation; 1-addition; 2-subtraction; 3-multiplication; 4-division var change = 0;//after operator needs to empty previous value var NUM1 = 0;//operation First Data var num2 = 0;/ /operation the second data var cunchuv
In the actual learning process, often do some small projects, you can learn the technology integrated application, get a certain sense of achievement, and exercise logical thinking ability.
Functions of this calculator code:
1, implementation of arithmetic, where division is to achieve the integer division
2. Realize the input function clearly
The core idea of implementing this function:
1, the function of this program is divided into state, a to
Use QT for the first time, configure environment variables and add QT paths to vs to find out for yourselfSource Code connections: 77508615 To do a simple calculator implementation is probably the use of these several filesThe first is the UI interface, open QT Designer can be edited, a bit like to do Android layoutThe second one is the. h file that corresponds to the UI interface, which contains the code
Demo: caculationtest
Preface
Have you ever thought about writing a calculator yourself? Enter some mathematical expressions to calculate and parse the generated results.
If you don't have one, you can start to think about it now. Maybe you will find that it takes a few seconds for you to calculate the expression, which makes Program Computing not that simple.
Assume that
For ease of understanding, we need
Write your own calculator one, function analysisThe user enters a similar expression like this (4+ 50)-((100 + 40) *5/2-3*2* 2/4+9) * ((((3 + 4)-4)-4), assuming that the expression contains no special symbols except spaces, ' + ', '-', ' * ', '/', and parentheses, and then straight Then write the code to parse the expression, achieve subtraction , The final result and the actual computer calculated results must be consistent.Second, the required knowl
This article mainly introduces how to implement the simple calculator of JS, and analyzes the tips of js to implement the computing function by using addition instances, for more information about how to implement a simple JavaScript calculator, see the examples in this article. Share it with you for your reference. Th
This article mainly introduces a simple calculator code program written in js, which is very practical. Interested partners can refer to a simple calculator code program recently compiled. Let's show it to you first.
The sharing code is as follows:
SUM: 1 2 3 4 5 6 */ 7 8 9 +- 0 00.% =
The addition, subtraction, multiplication, division, and Division Calculator must have been used. This article describes how to use php. The following is a good example. if you are interested, you can refer to php to implement the addition, subtraction, multiplication, division, and Division Calculator. The code is simple!
The code is as follows:
Header
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.