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"
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 first chapter in "big talk Design Patterns" is an example of a simple calculator built with a simple factory model, there is a factory class operaationfactory on the P10-P11 page in the book to construct instances of each operation class, but there is a problem here: 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
Effect Chart:
At the beginning did not take into account the Qing 0 and backspace two functions, Xi Hee, and then add the overall and traditional calculator than a little flaw.
Code:
Thank you for reading, I hope to help you, thank you for your support for this site!
Class count{public int Count (String a) {int n = a.length (); int result = 0;int num = 0;int p = 0;int L1 = A.indexof (' ('); int R1 = A.indexof (') '); String B = a.substring (l1+1,r1-1); int op = 0;if (L1 >= 0) return Count (b) + Result;else {for (int i=0; i This bird thing with iteration, in fact, not very good waste of space, more data is also easy to die, someone with a stack has not been studiedThis one's 600mm, and it's not clear.Https://leetcode.com/discuss/39454/accepted-infix-postfix
packagecom.hellojava.practice.test;importjava.awt.borderlayout;importjava.awt.gridlayout; importjava.awt.panel;importjava.awt.textfield;importjava.awt.event.actionevent;import java.awt.event.actionlistener;importjavax.swing.jbutton;importjavax.swing.jframe;import Javax.swing.jpanel;publicclassnumeratorThis article from the "12212886" blog, reproduced please contact the author!A simple calculator written in Java
(The tab with the principal means that you calculate the principal if you know the interest rate, age, and principal)The input of the decimal point can be restricted in the input of the interest rate and the input letter will be removed directly.Each tab has compounding and simple interest calculations and is immediately updated in the table below after you calculateThe table was jbable and the scroll bar was jscrollpane.Code I only use one class to write, so I don't put it up. Upload to GitHubT
DoublegetNum1 () {returnNUM1; } Public DoublegetNum2 () {returnnum2; } Public voidSETNUM1 (DoubleNUM1) { This. NUM1 =NUM1; } Public voidSETNUM2 (Doublenum2) { This. num2 =num2; } Public Static DoubleGetResult () {DoubleResult =0; returnresult; }}//class that computes addition inherits from the calculated classclassOperationaddextendsoperationtest{ Public Static DoubleGetResult () {returnnum1+num2; }}//classes that compute subtraction inherit from a calculated cla
I made a simple image similarity calculator using JAVA.Key Algorithms: Copy code 1 // full process 2 public static void main (String [] args) throws IOException {3 // get image 4 File imageFile = new File ("c: /1.jpg"); 5 Image image = ImageIO. read (imageFile); 6 // convert to grayscale 7 image = toGrayscale (image); 8 // scale down to a thumbnail of 32x32 9 image = scale (image ); 10 // obtain the gray pi
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.