可以计算加减乘除的计算器小程序package zj lec1; import java awt BorderLayout; import java awt FlowLayout; import java awt GridLayout; import java awt event ActionEvent; import java awt event ActionListener; import java math BigInteger; import javax swing JButton; import javax swing JFrame; import javax swing JLabel; import javax swing JPanel; import javax swing JTextField; public class 简易计算机 extends JFrame implements ActionListener { JTextField a b c d; JButton ok exit; public 简易计算机 { this setLayout new FlowLayout ; this add a new JTextField 10 ; a setText "0" ; a setHorizontalAlignment JTextField RIGHT ; this add b new JTextField 1 ; this add c new JTextField 10 ; c setText "0" ; c setHorizontalAlignment JTextField RIGHT ; this add ok new JButton " " ; this add d new JTextField 10 ; this add exit new JButton "Exit" ; a addActionListener this ; b addActionListener this ; c addActionListener this ; exit addActionListener this ; ok addActionListener this ; this setSize 540 70 ; this setTitle "简易计算机" ; this setVisible true ; this setResizable false ; } public static void main String[] args { new 简易计算机 ; } @Override public void actionPerformed ActionEvent e { if e getSource ok || e getSource c || e getSource a { BigInteger ia new BigInteger a getText ; BigInteger ic new BigInteger c getText ; String ib b getText ; 判断是用加法 还是减法 还是乘法 除法 if ib contains "+" { BigInteger id ia add ic ; d setText id toString ; } else if ib contains " " { BigInteger id ia subtract ic ; d setText id toString ; } else if ib contains " " { BigInteger id ia multiply ic ; d setText id toString ; } else if ib contains " " { BigInteger id ia divide ic ; d setText id toString ; } } else if e getSource exit { System exit 0 ; } } }">可以计算加减乘除的计算器小程序package zj lec1; import java awt BorderLayout; import java awt FlowLayout; import java awt GridLayout; import java awt event ActionEvent; import java awt event ActionListener; import java math BigInteger; import javax swing JButton; import javax swing J [更多]




























import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigInteger;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class 简易计算机 extends JFrame implements ActionListener {
JTextField a, b, c, d;
JButton ok, exit;
public 简易计算机() {
this.setLayout(new FlowLayout());
this.add(a = new JTextField(10));
a.setText("0");
a.setHorizontalAlignment(JTextField.RIGHT);
this.add(b = new JTextField(1));
this.add((c = new JTextField(10)));
c.setText("0");
c.setHorizontalAlignment(JTextField.RIGHT);
this.add(ok = new JButton("="));
this.add(d = new JTextField(10));


- 粉丝: 0
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 2017通信中级实务互联网技术考试解答参考-2题未解.docx
- 铁路通信工程施工工艺标准.doc
- 特教学校计算机教学方法的运用.docx
- 安卓手机在三维度手机商城购物全攻略.doc
- 江苏省计算机一级考试复习资料很全面的.doc
- 独立学院非计算机专业Python程序设计课程教学改革探索.docx
- 个人做电子商务.ppt
- 公路施工管理中计算机应用研究.doc
- 单片机开发语言特点研究.docx
- 大数据算法的输电线路故障分析研究.docx
- 基于项目驱动的计算机网络技术课程实践教学改革初探.docx
- asmeg-汇编语言资源
- 校园数字IP网络广播系统解决方案.doc
- 波分复用光纤通信系统课程设计.doc
- 现代智能停车场物联网系统方案设计概要.doc
- qqzeng-ip-C语言资源


