Table of Contents1 series Article address 2 a perfect equals method should contain content 3 modify part of the code in the Exchange Rate Converter 1 Series Article address java exchange rate calculator implementation (1) java exchange rate calculator Implementation (2)
This calculator is made up of two parts: a mxml file with a foreground interface, a background controller as file. The Mxml file is responsible for displaying the calculator interface, which handles the information sent by the user and calculates the results. In this tutorial we mainly study:
[List] The Application class
The Panel container
The Label element
The Grid container
The Button element[/list]
The
To write an application that simulates a calculator, using the Panel and grid layout, add a text box, 10 number buttons (0~9), 4 subtraction buttons, an equal sign button, a purge button, a square root button, a backspace button that asks the calculation formula and results to be displayed in a text box. The implementation effect is shown in the following illustration.
Java Simple
A small calculator made with bat/batch processingThis is my own bat/batch of small calculator, the following code directly copied into Notepad to save the. bat format can be used.
Support formulas, such as input: 12+12/(7-5), but only integer calculations are supported, decimals are not supported.
The utility is not very big, the technical content is not very hig
decimal point of the connection and so on
Add operations, you first have to determine whether the operator repeats
else if (type = = ' Add ') {
///Two consecutive operators
if (This.isop (val) This.isop ( This.lastval)) {return
this.infix;
}
Two consecutive numbers
else if (!this.isop (val) !this.isop (This.lastval)) {
newval = This.lastval * + val;
This.infix.pop ();
This.infix.push (this.lastv
Because it is a novice (very pure kind), so a bit messy, the code is very redundant (will be condensed later), naming rules please ignore. Of course, this calculator is only able to run up to the extent that there will be some inexplicable error, such as my index operation index only support integers and so on. After all, it is the first time to write a small thing alone, still very happy.1. Main section (L
Kerugaki-Blog Parkhttp://www.cnblogs.com/kailugaji/Software that needs to be prepared:Jdk,eclipse,exe4j,inno Setup CompilerFirst, the Java source program--Personal income tax:Package Math;import Javax.swing.JOptionPane;Kerugaki Http://www.cnblogs.com/kailugaji/public class Wrrtax {public static void main (string args[]) {string Mone Y Enter your income double x, y; Double tax=0; Joptionpane.showmessagedialog (NULL, "personal income tax
Use C # to write a calculator. The following figure, can complete the basic arithmetic.
Of course, this program is not even a self-contained calculator with Windows accessories.However, the logic of this program is still very worthwhile to think about, first of all, you should consider the user by +-*/= and other operational symbols, digital keys after the status of the
The examples in this article summarize the common methods used to write calculators in Java. Share to everyone for your reference, specific as follows:
Method One:
Package Wanwa;
Import java.awt.*;
Import java.awt.event.*;
Import javax.swing.*; public class Calculator extends JFrame {private Container Container; private gridbaglayout layout; private Gridbagconstra
INTs constraints; Private JTextField
The Code repetition rate is too high. It should be optimized and there is no time.
The setactioncommand () method can greatly reduce the amount of code.Code:
Import java. AWT .*;
Import java. AWT. event .*;
Import javax. Swing .*;
Public class test1 {
Public static void main (string [] ARGs ){
Calculator c = n
implemented by invoking the methods in each package, and we have a good understanding of the relationship between package and class invocation.After the experiment is completed, she organizes the code, organizes the general flow of the experiment report, and organizes the job submission format. And I am responsible for the final program inspection and calibration. Make sure there are no obvious unreasonable places. B,
The Set calculator assists java in processing the set operation of Structured Text
JAVA does not directly support set operations. Therefore, you must use nested loops to perform set operations such as intersection, union, and difference sets between text files. If there are many files, or if the file is large and cannot be directly computed in the memory, or you
Make a calculator like ageAccording to the topic, I made a calendar class and the date of the month and the day of the age, of course, the correct way more than one, the following is my source code and results:Package com. Date;Import Java.awt.FlowLayout;Import java.awt.event.ActionEvent;Import Java.awt.event.ActionListener;Import Java.sql.Date;Import Java.util.Calendar;Import java.util.EmptyStackException;
In fact, this Android computer, all the backstage ideas and "C # calculator Code" is exactly the same. The Win form program is ported to Android, from C # to Java in fact, because the basic syntax is very similar, the only difficulty is the Android XML layout part, unlike C # forms can be directly dragged.Or a calculator
Today to share a calculator program written in pure JavaScript code, many industries can use this program, such as the decoration budget, loan rates and so on.
First look at the effect after the completion:
Method One:
Write the code as follows:
code two:
method Three:
Above
Valuesetdefault (k,v) if K does not exist, set a default value of V, and return V, if K exists, return k corresponding to the Valuekeys () Get all the Keysvalues () Get all the Valuesiteritems () fori,jin D.iteritems ():p rint (i,j) update () M.update (n) m,n are Dictpop (k) Delete k:v corresponding element zip (L1,L2) high-order functions, Dict (Zip (l1,l2)) convert L1 and L2 to Mm=dict (a=1,b=10,c=3 , d=9) printsorted (Mm.iteritems (), key=lambdad:d[1],reverse=true)4. Other common op
Use java to create a simple calculator-general Linux technology-Linux programming and kernel information. The following is a detailed description. There are two classes in total. It only completes the +,-, X, and merge operations.
The GUI only uses AWT, which is easy to understand.
Calculator. java
Public class
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.