/** * Seek the powers of a number * x^y,y is a positive integer.The calculator can only calculate two number multiplication, cannot calculate n number multiplication at one time.* Know: 2^5= (2^2) ^2*2; 2^6= (2^2) ^3= ((4) ^2); 2^8= (2^2) ^4= (4^2) ^2= 16^2 * Get the rule: x^y= (x^2) ^ (Y/2), define A=X^2,B=Y/2, then get shape such as: x^y= a^b; * y assumes an odd number, then the decomposition of the last multiplied by a (as above 2^6 decompos
1. Calculator Experiment Report2.https://github.com/lollipopangel/test/tree/master3. Experiments7+8ClearVi. SummaryThrough this experiment let me to JFrame class, JPanel class, 5 kinds of Layout manager, text box, label and button use method, have a further understanding. Through the query to it has a deeper and greater understanding. At the same time in the experimental processAlso found their own many shortcomings, encountered a lot of difficulties,
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
Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ) , the plus + or minus sign - , Non-ne gative integers and empty spaces .Assume that the given expression was always valid.Some Examples:"1 + 1" = 2 "2-1 + 2" = 3 "(1+ (4+5+2)-3) + (6+8)" = 23Note: don't use the eval built-in library function.Problem Solving Ideas:You only need to identify the symbols that need to be
GitHub Address: Https://github.com/iamcarson/CarsonPARTNER: PenghongliangStudy No.: 201406114148Work with a partner handsome photo:Where to upgrade this time:1, improve the interface display, so that the overall interface looks more concise2, originally used StringBuffer to store the results and then displayed, after the upgrade using the database display3. Realized a function of emptyingThe effect is as follows::This time using MVC mode, there are data layer, control layer, display layerSummary
){ Panax NotoginsengBUT3 =NewJButton ("" +Str3[i]); -Pan3.add (BUT3);//Add the buttons in the array to the PAN3 container the } + AString str4[]={"0", ".", "=", "+"};//defines an array of STR4 arrays and initializes theJButton but4=NULL; + for(inti=0;i){ -But4 =NewJButton ("" +Str4[i]); $Pan4.add (BUT4);//Add the buttons in the array to the PAN4 container $ } -Frame.add (PAN1);//Add a pan1 container to a form -Frame.add (PAN2);//Add a pan2 con
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
Ideas are as follows:
Create a class that inherits the form class JFrame by extends;Creates a JFrame object and uses the SetVisible () method of the JFrame class to set the form visible;In the constructor, use the super () method to inherit the constructor method of the parent class;Use the Settitle () method to set the title of the form;Use the SetBounds () method to set the display position and size of the form;Use the Setdefaultcloseoperation () method to set the action of the form Close but
Calculators have been used, but their own writing is very emotional, this afternoon completed a primary calculator development, the main exercise for the graphic interface design, as well as event listening to the wording of the consolidation.
The main code is as follows:
package homework; Import java.awt.*; Import Java.awt.datatransfer.Clipboard; Import java.awt.datatransfer.StringSelection; Import java.
The program can realize the basic arithmetic operation, and can control the precision of the operation result effectively, and realize the memory related function.
Features are as follows:
MC: Clear Storage data
MR: Read the stored data on the screen
MS: Store the displayed data in memory
m+: Use the stored data plus the number displayed on the screen and update the value in the memory
M-: Subtract the number displayed on the screen and update the values in the storage with the stored data
←: D
. Finally, the numbers and operators are taken from the first team to perform the corresponding operations. (PS: I began to be affected by the class, with the stack to do, the idea is the idea, but WA, the results found that subtraction, you need to be the previous one minus, and the addition of the operation, if it is used in the stack, it will take the value of the front of the addition, and will not take the front of the symbol directly to So later instead of the queue to do, the pit of a fac
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.