资源简介
java的期末作业,用j2se实现一个简单的科学型计算器。包含有三角函数,对数,记忆存储等功能。
代码片段和文件信息
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.math.BigInteger;
import javax.swing.*;
public class Counter extends frame
{
//声明三个面板的布局
GridLayout gl1gl2gl3;
Panel p0p1p2p3;
JTextField tf1;
TextField tf2;
Button b0b1b2b3b4b5b6b7b8b9b10b11b12b13b14b15b16b17b18b19b20
b21b22b23b24b25b26b27b28b29b30b31b32b33b34b35b36b37b38b39b40
b41;
StringBuffer str;//显示屏所显示的字符串
double xy;//x和y都是运算数
int z;//Z表示单击了那一个运算符.0表示“+“1表示“-“2表示“*“3表示“/“...
static double m;//记忆的数字
public Counter()
{
gl1=new GridLayout(1700);//实例化三个面板的布局
gl2=new GridLayout(4100);
gl3=new GridLayout(4500);
tf1 = new JTextField(27);
tf1.setText(“0.“);
tf1.setHorizontalAlignment(JTextField.RIGHT);
tf1.setBorder(BorderFactory.createLineBorder(Color.lightGray));
tf1.setEditable(false);
tf1.setBackground(Color.white);
tf2=new TextField(10);//显示记忆的索引值
tf2.setEditable(false);
//实例化所有按钮、设置其前景色并注册监听器
b0=new Button(“Back“);
b0.setForeground(Color.red);
b0.addActionListener(new Bt());
b1=new Button(“CE“);
b1.setForeground(Color.red);
b1.addActionListener(new Bt());
b2=new Button(“C“);
b2.setForeground(Color.red);
b2.addActionListener(new Bt());
b3=new Button(“MC“);
b3.setForeground(Color.red);
b3.addActionListener(new Bt());
b4=new Button(“MR“);
b4.setForeground(Color.red);
b4.addActionListener(new Bt());
b5=new Button(“MS“);
b5.setForeground(Color.red);
b5.addActionListener(new Bt());
b6=new Button(“M+“);
b6.setForeground(Color.red);
b6.addActionListener(new Bt());
b7=new Button(“7“);
b7.setForeground(Color.blue);
b7.addActionListener(new Bt());
b8=new Button(“8“);
b8.setForeground(Color.blue);
b8.addActionListener(new Bt());
b9=new Button(“9“);
b9.setForeground(Color.blue);
b9.addActionListener(new Bt());
b10=new Button(“/“);
b10.setForeground(Color.red);
b10.addActionListener(new Bt());
b11=new Button(“sqrt“);
b11.setForeground(Color.red);
b11.addActionListener(new Bt());
b12=new Button(“4“);
b12.setForeground(Color.blue);
b12.addActionListener(new Bt());
b13=new Button(“5“);
b13.setForeground(Color.blue);
b13.addActionListener(new Bt());
b14=new Button(“6“);
b14.setForeground(Color.blue);
b14.addActionListener(new Bt());
b15=new Button(“*“);
b15.setForeground(Color.red);
b15.addActionListener(new Bt());
b16=new Button(“%“);
b16.setForeground(Color.red);
b16.addActionListener(new Bt());
b17=new Button(“1“);
b17.setForeground(Color.blue);
b17.addActionListener(new Bt());
b18=new Button(“2“);
b18.setForeground(Color.blue);
b18.addActionListener(new Bt());
b19=new Button(“3“);
b19.setForeground(Color.blue);
b19.addActionListener(new Bt());
b20=new Button(“-“);
b20.setForeground(Color.red);
b20.addActionListener(new Bt());
b21=new Button(“1/X“);
b21.setForeground(Color.red);
b21.addActionListener(new Bt());
b22=new Button(“0“);
- 上一篇:android悬浮窗口
- 下一篇:java权限系统概要设计说明书
相关资源
- java权限系统概要设计说明书
- javax.annotation
- 英汉小字典Java课程设计
- 将一段文字转化为哈夫曼编码JAVA实现
- 档案管理系统 源代码+数据库
- java的fastjson.jar包
- Java 利用poi 导出excel 工具类,超实用
- 广工JAVA作业报告
- 局部加权朴素贝叶斯
- 本科毕业论文java外文翻译
- 操作系统内存分配回收算法(first f
- POI实现Excel导入导出并附带加载进度条
- 运动会成绩管理系统,java课程设计源
- java项目经验 大概有20个
- Java(OOP)练习及作业
- ExcelUtils.java
- java+swing+mysql实现的学生信息管理系统
- 学生选课管理系统.rar
- mchange-commons-java-0.2.12.jar
- java培训视频资源获取.zip
- JAVA+SQL实训报告--工资管理系统
- BeanUtils工具
- 期末大作业扫雷游戏单机版源码java实
- 五子棋java jsp代码实现
- java-upload分片文件接收,分片文件合并
- httpclientjar包
- 小程序微信支付后台Java
- Java爬虫完整.zip
- j2ee外文期刊以及相应的中文翻译
- Java EE wed 简单的购物车应用开发
评论
共有 条评论