java高级计算器_求JAVA标准计算器与科学计算器转换源代码

展开全部

importjava.awt.*;importjava.awt.event.*;importjava.lang.*;importjavax.swing.*;publicclassCounterextendsFrame{//声明三个面板的布局GridLayoutgl1,gl2,gl3;Panelp0,p1,p2,p3;JTextFieldtf1;TextFieldtf2;Buttonb0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26;StringBufferstr;//显示屏所显示的字符串doublex,y;//x和y都是运算数intz;//Z表示32313133353236313431303231363533e58685e5aeb931333363386132单击了那一个运算符.0表示"+",1表示"-",2表示"*",3表示"/"staticdoublem;//记忆的数字publicCounter(){gl1=newGridLayout(1,4,10,0);//实例化三个面板的布局gl2=newGridLayout(4,1,0,15);gl3=newGridLayout(4,5,10,15);tf1=newJTextField(27);//显示屏tf1.setHorizontalAlignment(JTextField.RIGHT);tf1.setEnabled(false);tf1.setText("0");tf2=newTextField(10);//显示记忆的索引值tf2.setEditable(false);//实例化所有按钮、设置其前景色并注册监听器b0=newButton("Backspace");b0.setForeground(Color.red);b0.addActionListener(newBt());b1=newButton("CE");b1.setForeground(Color.red);b1.addActionListener(newBt());b2=newButton("C");b2.setForeground(Color.red);b2.addActionListener(newBt());b3=newButton("MC");b3.setForeground(Color.red);b3.addActionListener(newBt());b4=newButton("MR");b4.setForeground(Color.red);b4.addActionListener(newBt());b5=newButton("MS");b5.setForeground(Color.red);b5.addActionListener(newBt());b6=newButton("M+");b6.setForeground(Color.red);b6.addActionListener(newBt());b7=newButton("7");b7.setForeground(Color.blue);b7.addActionListener(newBt());b8=newButton("8");b8.setForeground(Color.blue);b8

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值