java计算机小程序百度网盘,如何编写JAVA计算器小程序

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Calculator implements ActionListener{

private double data1=0.0,data2=0.0;

private String t_content;

boolean number = false;

short key=-1;

short pkey=-1;

Frame frame=new Frame("Calculator");

TextField textfield=new TextField(30);

Button backspace=new Button("Backspace");

Button ce=new Button("CE");

Button c0=new Button("C");

Panel p1=new Panel();

Panel p2=new Panel();

String names[]={"7","8","9","/","sqrt","4","5","6","*","%","1","2","3","-","1/x","0","+/-",".","+","="};

Button bb[]=new Button[names.length];

public static void main(String[] args) {

// TODO Auto-generated method stub

Calculator cal=new Calculator();

cal.go();

}

public void go()

{

frame.setSize(300,200);

frame.setLayout(new BorderLayout());

Font fonts=new Font("楷体_GB2312",Font.PLAIN,12);

p1.setFont(fonts);

p1.setLayout(new GridLayout(2,1,5,10));

textfield.setFont(fonts);

p1.add(textfield,null);

backspace.addActionListener(this);

ce.addActionListener(this);

c0.addActionListener(this);

p1.add(backspace,null);

p1.add(ce,null);

p1.add(c0,null);

p2.setLayout(new GridLayout(4,5,5,5));

for(int i=0;i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值