手机计算机的java代码 手机计算机的java代码是什么( 三 )


sum();
}
if(sign.equals("-")){
sub();
}
if(sign.equals("*")){
mul();
}
if(sign.equals("/")){
div();
}
if(sign.equals("%")){
sur();
}
}
//result
public void Result(){
if(result%1!=0)
jl.setText(""+result);
else
{
int i=(int)result;
jl.setText(""+i);
}
}
@Override
public void actionPerformed(ActionEvent e) {
//System.out.println(sb.toString());
// 1~9
for(int i=0;i9;i++){
if(e.getSource()==jb[i]!sb.toString().equals("0")){
sb.append(jb[i].getText());
jl.setText(sb.toString());
}
else if(e.getSource()==jb[i]sb.toString().equals("0")){
int d=sb.length();
sb.delete(0, d);
sb.append(jb[i].getText());
jl.setText(sb.toString());
}
}
//0
if(e.getSource()==jb[10]!sb.toString().equals("0")){
sb.append(jb[10].getText());
jl.setText(sb.toString());
}
//.
if(e.getSource()==jb[9]dot==0!sb.toString().equals("")){
dot++;
sb.append(jb[9].getText());
jl.setText(sb.toString());
}
//=
if(e.getSource()==jb[11]!sb.toString().equals("")){
same();
Result();
int d=sb.length();
sb.delete(0, d);
dot=0;
}
//+
if(e.getSource()==jbs!sb.toString().equals("")){
if(sign!="+"sign!=null)
same();
else
sum();
sign ="+";
Result();
int d=sb.length();
sb.delete(0, d);
dot=0;
}
//-
if(e.getSource()==jbo!sb.toString().equals("")){
if(fnum==0)
fnum=2*Double.parseDouble(sb.toString());
if(sign!="-"sign!=null)
same();
else
sub();
sign ="-";
Result();
int d=sb.length();
sb.delete(0, d);
dot=0;
}
//*
if(e.getSource()==jba!sb.toString().equals("")){
if(fnum==0)
fnum=1;
if(sign!="*"sign!=null)
same();
else
mul();
sign ="*";
Result();
int d=sb.length();
sb.delete(0, d);
dot=0;
}
///
if(e.getSource()==jbb!sb.toString().equals("")){
if(fnum==0)
fnum=Math.pow(Double.parseDouble(sb.toString()),2);
if(sign!="/"sign!=null)
same();
else
div();
sign ="/";
Result();
int d=sb.length();
sb.delete(0, d);
dot=0;
}
//%
//if(e.getSource()==jby!sb.toString().equals("")){
//if(fnum==0){
//fnum=Double.parseDouble(sb.toString());
//result=fnum;
//}
//else {
//if(sign!="%"sign!=null)
//same();
//else{
//lnum=Double.parseDouble(sb.toString());
//normal=new Normal(fnum,lnum);
//fnum=normal.surpuls();
//result=fnum;
//}
//}
//sign ="%";
//Result();
//int d=sb.length();
//sb.delete(0, d);
//dot=0;
//}
//clear
if(e.getSource()==jbc){
int d=sb.length();
sb.delete(0, d);
jl.setText("0");
dot=0;
fnum=0;
lnum=0;
sign=null;
}
}
}
class viewScientific extends viewNormal{
public viewScientific(String title){
super(title);
setBounds(200,200,800,500);
}
}
//等号以后输入符号用不手机计算机的java代码了手机计算机的java代码, String转 double 本来就有错误手机计算机的java代码,手机计算机的java代码你可以用我手机计算机的java代码的扩展成科学型的 。
如何用JAVA语言编写计算器小程序?具体代码如下手机计算机的java代码:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Calculatorextends JFrame implements ActionListener{
private JFrame jf;
private JButton[] allButtons;
private JButton clearButton;

推荐阅读