复杂计算器java代码 复杂计算器java代码大全(11)


to="-";
}
});
}
if(i==3)
{
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String ma=text.getText();
cq=Double.parseDouble(ma);
if(what==null)
{
tool=cq;
what="cq";
}
else
{
tool=tool/cq;
text.setText(String.valueOf((tool)));
}
vc.add("a");
vc1.add("v1");
to="/";
}
});
}
if(i==7)
{
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String ma=text.getText();
cs=Double.parseDouble(ma);
if(what==null)
{
tool=cs;
what="cs";
}
else
{
tool=tool*cs;
text.setText(String.valueOf((tool)));
}
vc.add("a");
vc1.add("v1");
to="*";
}
});
}
if(i==13)
{
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String ma=text.getText();
dy=Double.parseDouble(ma);
if(what=="add")
{
jg=String.valueOf((tool+dy));
}
if(what=="jq")
{
jg=String.valueOf((tool-dy));
}
if(what=="cs")
{
jg=String.valueOf((tool*dy));
}
if(what=="cq")
{
jg=String.valueOf((tool/dy));
}
if(what==null)
{
if(to=="+")
{
tool=add;
jg=String.valueOf(tool+dy);
}
else if(to=="-")
{
tool=jq;
jg=String.valueOf(dy-tool);
}
else if(to=="*")
{
tool=cs;
jg=String.valueOf(dy*tool);
}
else if(to=="/")
{
tool=cq;
jg=String.valueOf(dy/tool);
}
else
{
jg=String.valueOf(dy);
}
}
text.setText(jg);
Vec.clear();
Vec.add(".");
vc.add("a");
vc1.add("v1");
what=null;
tool=0;
}
});
}
}
}
}
class Centernorth extends JPanel {
public Centernorth() {
final JTextField text=Tool.getinstance().getfield();
}
}
class Centerpanel extends JPanel {
public Centerpanel() {
this.setLayout(new BorderLayout(8,7));
Centernorth cn=new Centernorth();
Centercenter cc=new Centercenter();
Centerwest cw=new Centerwest();
this.add(cn,BorderLayout.NORTH);
this.add(cc,BorderLayout.CENTER);
this.add(cw,BorderLayout.WEST);
}
}
class Centerwest extends JPanel {
public Centerwest() {
}
}
class Northpanel extends JPanel {
private JTextField tf;
public Northpanel() {
tf=Tool.getinstance().getfield();
this.add(tf);
}
}
------------------------------------------------------------
才子_辉祝您愉快!
java实现复杂计算器import java.util.Scanner;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Kyo
{
public static void main(String[] args)
{
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine se = sem.getEngineByName("js");
Scanner scan = new Scanner(System.in);
while(true)
{
System.out.println("输入一个式子:");
String jsonstr = scan.nextLine().trim();
try
{
double d = Double.parseDouble(se.eval("(" + jsonstr + ")").toString());
System.out.printf("%s=%.1f%n", jsonstr, d);
}
catch(ScriptException e)
{
System.err.println("输入的式子不合法,退出程序");
scan.close();
break;
}
}
}
}
复杂计算器java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于复杂计算器java代码大全、复杂计算器java代码的信息别忘了在本站进行查找喔 。

推荐阅读