Discover lines of code calculator, include the articles, news, trends, analysis and practical advice about lines of code calculator on alibabacloud.com
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
Copy CodeThe code is as follows:
Single-channel Branch
if (Isset ($_get["sub"]))
{
$num 1=true;//Whether the number 1 is an empty tag
$num 2=true;//Whether the number 2 is an empty tag
$numa =true;//Number 1 is a number
$numb =true;//Number 2 is a bit number
$message = "";
Determines whether the number 1 is empty
if ($_get["NUM1"]== "")
{
$num 1=false;
$message. = "The first number cannot be empty";
}
Determine if the number 1 is a num
Copy Code code as follows:
PS: Here again for you to recommend two online calculator this site, are implemented with JS, and powerful, I believe that in-depth understanding of JavaScript math and web design will help:
Online Standard calculator:http://tools.jb51.net/jisuanqi/jsq
Online Science calculator:Http://tools.jb51.net/jisuanqi/jsqkexue
Benli and:");scanf ("%lf", f);printf ("Please enter the Principal:");scanf ("%lf", p);printf ("Please enter the target age:");scanf ("%d", n);i = POW ((f/p), 1.0/n)-1;printf ("Annual rate of Return:%0.2lf\n", i);}void Getmutualfund (){printf ("Please enter the amount of the annual fixed investment:");scanf ("%lf", p);printf ("Please enter annual yield (percentage):");scanf ("%lf", i);printf ("Please enter the number of years of investment:");scanf ("%d", n);f = p* (1+i/100) * (Pow ((1+i/100), N
Sometimes it's nice to write something with a script .CodeFrom Tkinter import *reset=truedef buttoncallback (Event): Global label Global Reset num=event.widget[' text '] I F num== ' C ': label[' text ']= "0" return if num in "=": label[' text ']=str (eval (label[' text '])) Reset=true return s=label[' text '] if s== ' 0 ' or reset==true:s= "" Reset=false label[' text ']= s+num# main Window ROOT=TK () root.wm_title ("calculator") #显示栏1label =lab
= ' LPAR ', value= ' ("), Token (Name= ') NUM ', value= '), Token (name= ' ADD ', value= ' + '), Token (name= ' NUM ', value= ' 3 '), Token (name= ' Rpar ', value= ')]
Any tag that is not in Token_map is assumed to be a number. Our word breaker lacks a property called validation to prevent the non-numeric acceptance, but fortunately, the operator will deal with it later.That's itStep Two: syntax definition
The parser I choose is implemented from a local vertical parser, which comes from a
The modified calculator Code has the following problem: If you need to add a new operation class, in addition to modifying the interface code, you also need to add a new statement in the switch of operaationfactory! Using C # reflection technology can solve the problem well. The following code does not use DLL. For exa
Js expression calculator Code. For more information, see. :
Code:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
values during calculation.
function Value(value){ this.value = value || 0;}Value.prototype.toString = function(){ return this.value.toString(); };
Code Implementation of the createOperator function:
// IIFEvar createOperator = (function () {// name: "+", "-", "*", "/" // OPERATOR: return function (name, struct) {// closure function var Foo = function () {// obtain two operands var args = arguments; var nums = []. slice. call (arguments); nums = nu
Code
12345678910111213141516171819202122232425262728293031323334353637383940414243
from tkinter import *reset=Truedef buttonCallBack(event):global labelglobal resetnum=event.widget[‘text‘]if num==‘C‘:label[‘text‘]="0"returnif num in "=":label[‘text‘]=str(eval(label[‘text‘]))reset=Truereturns=label[‘text‘]if s==‘0‘ or reset==True:s=""reset=Falselabel[‘text‘]=s+num#主窗口root=Tk()root.wm_title("计算器")#显示栏1label=Label(root,text="0"
In fact, this program is the first sophomore semester in Java, a normal job, at that time only required to produce a few random matrices and the calculation of these matrices.So I didn't go to the present so rich and practical function. But at that time was quite want to do, but some do not know how to achieve.Now is the junior semester, before soon after the end of the exam, idle to the matter before the fall of this thing to fill up, but also a big worry about the old one.The
The following small series for everyone to bring a PHP mortgage calculator instance Code, equal and principal interest, equal to the principal. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.
Examples are as follows:
DEBX (); function Debx () {$dkm = 240;//Loan month, 20 is 240 months $dkTotal = 10000;//Total loan $d
to the button[Mybotton settitle:@ "calculation" forstate:uicontrolstatenormal];Color of the default state "calculation"[Mybotton Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatehighlighted];Color of the "calculated" highlight state[Mybotton Settitlecolor:[uicolor Bluecolor] forstate:uicontrolstatenormal];Automatically resize the button[Mybotton SizeToFit];Add to Root view[Self.view Addsubview:mybotton];Implement Click events[Mybotton addtarget:self Action: @selector (calculate) forcontr
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.