JAVA课程设计简单的计算器(含代码)
《JAVA课程设计简单的计算器(含代码)》由会员分享,可在线阅读,更多相关《JAVA课程设计简单的计算器(含代码)(34页珍藏版)》请在装配图网上搜索。
1、IJava程序课程设计任务书程序课程设计任务书一、主要任务与目标 1. 掌握java语言2. 创建一个简单的计算器,具有简单人机交互界面,易于操作,便于进行数据之间的简单运算。 二、具体要求(包括技术要求等):1)能够实现基本的加、减、乘、除四则运算及开方,乘方运算;2)如输入数据时,出现错误,可以修改; 3)运算结果能正确显示;可以清零;4)拥有登陆注册功能;5)可以查看历史记录;学习并掌握以下技术:Java、awt,swing等熟练使用以下开发工具:Jdk,JCreate 等实现计算器的上述的功能。三、计划进度112月28日12月29日:搜集资料、查阅文献,确定选题212月30日-12月3
2、1日:需求分析,系统设计,系统功能模块完善31月1日-1月3日:编程实现系统、系统测试与修改41月4日- 1月6日:课程设计报告撰写51月 7日- 1月 8日:课程设计报告答辩四、主要参考文献1 耿祥义,张跃平.java大学实用教程(第二版).电子工业出版社.2008年5月II目目 录录JAVA程序课程设计任务书程序课程设计任务书.II目目 录录.III第第1章章 引言引言 .11.1 课程设计内容.11.2 任务分工.1第第2章章 计算器定义计算器定义 .22.1 计算器登陆注册界面概述.22.1.1 计算器功能概述.22.1.2 计算结果的储存与查看功能概述.22.2 本章小结.2第第3章
3、章 计算器的具体实现计算器的具体实现 .33.1界面设计.33.1.1用户登陆界面图.33.1.3 计算器主界面.83.2计算功能实现.93.4 本章小结.14第第4章章 结束语结束语 .14致谢致谢 .15参考文献参考文献 .15附录附录 源代码源代码 .15/*引用数据包里的类与方法引用数据包里的类与方法*/.151第第1章章 引言引言1.11.1 课程设计内容课程设计内容这是我组设计的计算器会有一些独特的功能,本项目用到了Java中的GUI界面和swing组件以及awt布局,所以简单易用,它能完成如下的几个功能:(1)数据计算处理功能 点击按钮中的数字键和运算符键就能进行简单的加、乘、乘
4、、除四则运算及三角函数,开方,乘方运算 ;如果输入有误时可以按C撤销后重新输入新数据,有储存修改键;(2)查询功能 查询功能可以迅速方便地查找到相应时段的执行的操作及结果。(3)计算器使用权限功能对个人的操作实现口令。用户在使用计算器前需通过登录界面登录,以保护计算器的数据安全。未有登录资料的先进行注册。(4)时间显示功能 在计算器上显示现在的时间,便于把握时间;1.21.2 任务分工任务分工2第第2章章 计算器定义计算器定义2.12.1 计算器登陆注册界面概述计算器登陆注册界面概述这是对计算器使用权限功能的添加,这是以后软件开发的一个重点发展方向。用户在使用计算器前需通过登录界面登录,以保护
5、计算器的数据安全和使用权限的设定。未有登录资料的必须先进行注册;2.1.1 计算器功能概述计算器功能概述一个计算器如果只有数据计算处理功能,或者是点击按钮中的数字键和运算符键就能进行简单的加、乘、乘、除四则运算是远远不够的,这太普通了,因此加入三角函数,开方,乘方运算 ,并且如果输入有误时可以按C撤销后重新输入新数据,有储存修改键;最主要是加入了查询功能:查询功能可以迅速方便地查找到相应时段的执行的操作及结果。还有就是计算器使用权限的设定,即登陆注册界面,用户在使用计算器前需通过登录界面登录,以保护计算器的数据安全。未有登录资料的先进行注册。2.1.2 计算结果的储存与查看功能概述计算结果的储
6、存与查看功能概述计算结果有了,但是一般的计算器不能查询之前进行的操作和结果,不得不重新计算,这就带来了不少麻烦,我组设计制作的计算器拥有直接查看历史记录的功能,还附有各个操作的时间,便于确认;2.22.2 本章小结本章小结这一章介绍了当前进销存管理系统应该具备的功能模块,并提供了市面上比较流行的进销存管理系统作为参考。在这一章中,我们可以了解什么是进销存管理系统,当前进销存管理系统的市场需求,还有一个进销存管理系统应该的开发目标。3第第3章章 计算器的具体实现计算器的具体实现界面是系统之间最直接的交互界面,界面的友好性体现了软件设计的质量, 并在很大程度上决定了软件是否成功。3.13.1界面设
7、计界面设计1.界面设计界面设计界面设计要求用GUI,界面设计中有用到swing组件的TextField和Button,用到awt中的BorderLayout和GridLayout布局管理方式。3.1.1用户登陆界面图用户登陆界面图如图3.1.1和3.1.2所示图图3.1.1 用户登录模块框图用户登录模块框图4图图3.1.23.1.2 用户登录界面用户登录界面loginDialog与compareUserData函数的作用是用户登录界面创建和检测用户登的合法性,并确认用户输入了合法的登录名和口令。部分代码:private void loginDialog() login = new JDialo
8、g(); login.setTitle(登录); login.setLayout(new FlowLayout(); login.add(new JLabel(用户名:); final JTextField name = new JTextField(10); login.add(name); login.add(new JLabel(密 码:); final JPasswordField password = new JPasswordField(10); password.setEchoChar(*); login.add(password); JButton confirm = new
9、JButton(登录); confirm.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if (compareUserData(name.getText().trim(), new String(password.getPassword() login.setVisible(false); f.setVisible(true); else JOptionPane.showMessageDialog(login, 用户名或密码错误!, 错误提示, JOptionPane.ERRO
10、R_MESSAGE); 5 ); login.add(confirm); final JDialog regDialog = new JDialog(login, 注册, true); registerDialog(regDialog); JButton register = new JButton(注册); register.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) regDialog.setVisible(true); ); login.add(register); l
11、ogin.setSize(200, 130); login.setResizable(false); login.setLocationRelativeTo(null); login.setVisible(true);private boolean compareUserData(String name, String password) try RandomAccessFile out = new RandomAccessFile(user.dat, rw);String fname, fpassword = null;while (out.getFilePointer() 1) tResu
12、lt.setText(temp.delete(temp.length()-1, temp.length().toString(); else tResult.setText(0); else if (s.equals(C) /如果是C删除当前计算 tResult.setText(0); tf.setText(); num1.replace(0, num1.length(), 0); num2.replace(0, num2.length(), 0); isExist = false; operate = ; else if (s.equals() tResult.setText( + Math
13、.PI); else if (s.equals(sin) String temp = tResult.getText().trim(); double dtemp = Math.PI / 180.0 * Double.parseDouble(temp); tResult.setText(+Math.sin(dtemp); save(sin + ( + temp + ) = + Math.sin(dtemp); else if (s.equals(cos) String temp = tResult.getText().trim();10 double dtemp = Math.PI / 180
14、.0 * Double.parseDouble(temp); tResult.setText(+Math.cos(dtemp); save(cos + ( + temp + ) = + Math.cos(dtemp); else if (s.equals(tan) String temp = tResult.getText().trim(); double dtemp = Math.PI / 180.0 * Double.parseDouble(temp); tResult.setText(+Math.tan(dtemp); save(tan + ( + temp + ) = + Math.t
15、an(dtemp); else if (s.equals(log) String temp = tResult.getText().trim(); double dtemp = Double.parseDouble(temp); tResult.setText(+Math.log10(dtemp); save(log + ( + temp + ) = + Math.log(dtemp); else if (s.equals(MC) /如果是MC则清除缓冲区 String temp = 0; memory.replace(0, memory.length(), temp); bM.setText
16、( ); else if (s.equals(MR) /如果按键为MR则恢复缓冲区的数到文本框 tResult.setText(memory.toString(); else if (s.equals(MS) /如果按键为MS则将文本框的数存入缓冲区 String s1 = tResult.getText().trim(); memory.replace(0, memory.length(), s1); bM.setText(M); else if (s.equals(M+) /如果按键为MS则将文本框值与缓冲区的数相加但不显示结果 String temp1 = tResult.getText
17、().trim(); double dtemp = Double.parseDouble(temp1); String temp2 = memory.toString(); if (temp2.length() = 0) temp2 = 0; dtemp += Double.parseDouble(temp2); temp1 = String.valueOf(dtemp); memory.replace(0, memory.length(), temp1); bM.setText(M); else if (s.equals(1/x) /如果按键为1/x则将文本框中的数据为它的倒数11 Stri
18、ng temp = tResult.getText().trim(); double dtemp = Double.parseDouble(temp); tResult.setText(+1/dtemp); else if (s.equals(sqrt) /如果按键为sqrt则将文本框中的内容求平方根 String temp = tResult.getText().trim(); double dtemp = Double.parseDouble(temp); tResult.setText(+Math.sqrt(dtemp); save(sqrt + ( + temp + ) = + Mat
19、h.sqrt(dtemp); else if (s.equals(x2) /如果按键为x2则将文本框中的内容求平方 String temp = tResult.getText().trim(); double dtemp = Double.parseDouble(temp) * Double.parseDouble(temp); tResult.setText(+dtemp); save(temp + 2 = + Math.sin(dtemp); else if (s.equals(+/-) String temp = tResult.getText().trim(); double dtem
20、p = -Double.parseDouble(temp); if (dtemp != 0) tResult.setText(+dtemp); else if (s.equals(+) | s.equals(-) | s.equals(*) | s.equals(/) /加减乘除按键求结果 if (operate = ) num1 = num1.replace(0, num1.length(), tResult.getText().trim(); isClear = true; tf.setText(num1.toString() + s); else if (!isExist) num2 =
21、 num2.replace(0, num2.length(), tResult.getText().trim(); String rlt = null; double a = Double.parseDouble(num1.toString().trim(); double b = Double.parseDouble(num2.toString().trim(); switch(operate) case +: rlt = + (a + b); break; case -: rlt = + (a - b); break; case *: rlt = + (a * b); break; cas
22、e /: rlt = + (a / b); break; tResult.setText(rlt); tf.setText( + num1.toString() + operate + num2.toString(); num1.replace(0, num1.length(), rlt); isClear = true; 12 operate = s.charAt(0); else if (s.equals(=) /按键=显示结果 if (!isExist) num2 = num2.replace(0, num2.length(), tResult.getText().trim(); isE
23、xist = true; if (operate != ) String rlt = null; double a = Double.parseDouble(num1.toString().trim(); double b = Double.parseDouble(num2.toString().trim(); switch(operate) case +: rlt = + (a + b); break; case -: rlt = + (a - b); break; case *: rlt = + (a * b); break; case /: rlt = + (a / b); break;
24、 tResult.setText(rlt); /存入文件 save( + a + + operate + + b + = + rlt); tf.setText( + num1.toString() + operate + num2.toString(); num1.replace(0, num1.length(), rlt); isClear = true; else if(s.equals(.) /单击“小数点”的处理 /当前结果中不存在. if(tResult.getText().trim().indexOf(.) = -1) StringBuffer tmp = new StringBu
25、ffer(tResult.getText().trim(); tResult.setText(tmp.append(s).toString(); else /数字键的处理 if (!Character.isDigit(tResult.getText().charAt(0) tResult.setText(); if (isClear) isClear = false; tResult.setText(); if (isExist) isExist = false; tf.setText(); operate = ; tResult.setText();13 StringBuffer tmp =
26、 new StringBuffer(tResult.getText().trim(); if (tmp.toString().equals(0) tmp.setLength(0); tResult.setText(tmp.append(s).toString(); /end actionPerformed3.3 计算结果的储存功能与查看功能计算结果的储存功能与查看功能1通过save函数来实现结果的储存功能;部分代码:private void save(String s) final SimpleDateFormat sdf = new SimpleDateFormat(yyyy年MM月dd日
27、HH:mm:ss :);String time = sdf.format(new Date(System.currentTimeMillis(); try File file = new File(data.txt); if (!file.exists() file.createNewFile(); char ch = new char(int)file.length(); FileReader in = new FileReader(file); in.read(ch); in.close(); FileWriter out = new FileWriter(file); String tm
28、p = new String(ch); out.write(tmp.trim() + System.getProperty(line.separator); out.write(time + s).trim() + System.getProperty(line.separator); out.close(); catch(IOException e) e.printStackTrace(); 2通过“查看”选项中的“历史记录”来查看历史结果,此showRecord函数的作用就是把储存在data.txt中的历史记录显示在一面板中;部分代码如下: private void showRecord(
29、) JDialog dialog = new JDialog(f, 历史记录, true); JTextArea area = new JTextArea(); area.setEditable(false); dialog.add(new JScrollPane(area); dialog.setSize(640, 480); dialog.setLocationRelativeTo(null); try File file = new File(data.txt); if (!file.exists() file.createNewFile(); char ch = new char(in
30、t)file.length();14 FileReader in = new FileReader(file); in.read(ch); in.close(); area.setText(new String(ch); catch(IOException e) e.printStackTrace(); dialog.setVisible(true); 3.43.4 本章小结本章小结本章介绍了计算器的具体实现和部分关键代码,其中包括用户登录界面创建和检测用户登的合法性所要用到的loginDialog与compareUserData函数,注册界面的设计与储存,主界面的框架设计和计算功能,储存与查
31、看历史记录功能的具体实现。第第4章章 结束语结束语在做本项目是时候,会遇到很多小问题,比如说:如何保存输入的数字和下一个数进行加、减、乘、除运算。如何保存结果与如何进行登陆注册页面的添加及用户信息的储存,经过不断地尝试与调整,此次课程设计让我们更了解熟悉了Java中的图形用户界面和它的编程方式。在完成课题的过程中也不断充实了自己,学习到了很多以前没有学习到的知识,收获很大。最大的收获就是对大学学习的总结和培养了解决困难的信心和能力,使我们对所学知识能够融会贯通,又不断丰富了新知识。Java计算器设计使得我们对所学的专业课有了更为深刻的认识,使得知识得到了巩固和提高。15致谢致谢参考文献参考文献
32、1 耿祥义,张跃平.java大学实用教程(第二版).电子工业出版社.2008年5月附录附录 源代码源代码/*/*引用数据包里的类与方法引用数据包里的类与方法*/*/import java.awt.BorderLayout;import java.awt.Checkbox;import java.awt.CheckboxGroup;import java.awt.Color;import java.awt.Container;import java.awt.FlowLayout;import java.awt.Font;import java.awt.GridLayout;import java
33、.awt.Toolkit;import java.awt.datatransfer.Clipboard;import java.awt.datatransfer.DataFlavor;import java.awt.datatransfer.StringSelection;import java.awt.datatransfer.Transferable;import java.awt.datatransfer.UnsupportedFlavorException;import java.awt.event.ActionEvent;import java.awt.event.ActionLis
34、tener;import java.awt.event.InputEvent;import java.awt.event.KeyEvent;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.RandomAccessFile;import java.text.SimpleDateFormat;import java.util.Date;16import javax.swing.Box;import javax.swing
35、.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JScrollPane;import j
36、avax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.KeyStroke;import javax.swing.Timer;/*Java计算器 主类*/public class Calculator implements ActionListener JFrame f; JDialog login, addUser; JMenu mView; JMenu mEdit; JMenu mHelp; JMenuItem mRecord; JMenuItem mCopy; JMenuItem mPaste; JMen
37、uItem about; JTextField tResult, tf; JButton bNumber; JButton bOperator; JButton bOther; JButton bM; JButton Pi; JButton sin, cos, tan; JButton log; char operate = ; /操作数 StringBuffer num1 = new StringBuffer(0), num2 = new StringBuffer(0); boolean isExist = false, isClear = false; /M系列 StringBuffer
38、memory = new StringBuffer(20); /系统剪切板17 Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); /Java计算器 构造器 public Calculator() f = new JFrame(计算器); Container contentPane = f.getContentPane(); final SimpleDateFormat sdf = new SimpleDateFormat(当前时间 HH:mm:ss); Timer time = new Timer(1000,
39、new ActionListener() public void actionPerformed(ActionEvent e) f.setTitle(计算器 + sdf.format(new Date(System.currentTimeMillis();); time.start();/*Java计算器 菜单的创建*/ JMenuBar mBar = new JMenuBar(); mBar.setOpaque(true); mView = new JMenu(查看(V); mView.setMnemonic(KeyEvent.VK_V); mRecord = new JMenuItem(历
40、史纪录(H); mRecord.setMnemonic(KeyEvent.VK_H); mRecord.addActionListener(this); mView.add(mRecord); mEdit = new JMenu(编辑(E); mEdit.setMnemonic(KeyEvent.VK_E); mCopy = new JMenuItem(复制(C);mCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK); mCopy.addActionListener(this); mEd
41、it.add(mCopy); mPaste = new JMenuItem(粘贴(P);mPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK); mPaste.addActionListener(this); mEdit.add(mPaste); mHelp = new JMenu(帮助(H); mHelp.setMnemonic(KeyEvent.VK_H); about = new JMenuItem(关于计算器); about.addActionListener(this); mH
42、elp.add(about);18 mBar.add(mView); mBar.add(mEdit); mBar.add(mHelp); f.setJMenuBar(mBar); contentPane.setLayout(new BorderLayout(); JPanel pTop = new JPanel(); pTop.setLayout(new BorderLayout(); tf = new JTextField(); tf.setHorizontalAlignment(JTextField.RIGHT); tf.setEditable(false); pTop.add(tf, B
43、orderLayout.NORTH); tResult = new JTextField(0, 20); tResult.setFont(new Font(黑体, Font.BOLD, 28); tResult.setHorizontalAlignment(JTextField.RIGHT); tResult.setEditable(false); pTop.add(tResult, BorderLayout.CENTER); contentPane.add(pTop,BorderLayout.NORTH); JPanel pBottom = new JPanel(); pBottom.set
44、Layout(new BorderLayout(); JPanel pLeft = new JPanel(); pLeft.setLayout(new GridLayout(5,2,3,3); bM = new JButton( ); bM.setEnabled(false); pLeft.add(bM);/*Java计算器 功能键定义*/ Pi = new JButton(); Pi.addActionListener(this); Pi.setForeground(Color.red); pLeft.add(Pi); bOther = new JButton(MC); bOther.add
45、ActionListener(this); bOther.setForeground(Color.red); pLeft.add(bOther); sin = new JButton(sin); sin.addActionListener(this); sin.setForeground(Color.red); pLeft.add(sin);19 bOther = new JButton(MR); bOther.addActionListener(this); bOther.setForeground(Color.red); pLeft.add(bOther); cos = new JButt
46、on(cos); cos.addActionListener(this); cos.setForeground(Color.red); pLeft.add(cos); bOther = new JButton(MS); bOther.addActionListener(this); bOther.setForeground(Color.red); pLeft.add(bOther); tan = new JButton(tan); tan.addActionListener(this); tan.setForeground(Color.red); pLeft.add(tan); bOther
47、= new JButton(M+); bOther.addActionListener(this); bOther.setForeground(Color.red); pLeft.add(bOther); log = new JButton(log); log.addActionListener(this); log.setForeground(Color.red); pLeft.add(log); pBottom.add(pLeft,BorderLayout.WEST); JPanel pRight = new JPanel(); pRight.setLayout(new BorderLay
48、out(); JPanel pUp = new JPanel(); pUp.setLayout(new GridLayout(1,3,3,0); bOther = new JButton(BackSpace); bOther.addActionListener(this); bOther.setForeground(Color.red); pUp.add(bOther);20 bOther = new JButton(CE); bOther.addActionListener(this); bOther.setForeground(Color.red); pUp.add(bOther); bO
49、ther = new JButton(C); bOther.addActionListener(this); bOther.setForeground(Color.red); pUp.add(bOther);/*Java计算器 数字键盘区定义*/ JPanel pDown = new JPanel(); pDown.setLayout(new GridLayout(4,5,3,2); bNumber = new JButton(7); bNumber.setMnemonic(KeyEvent.VK_7); bNumber.setForeground(Color.blue); bNumber.a
50、ddActionListener(this); pDown.add(bNumber); bNumber = new JButton(8); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNumber); bNumber = new JButton(9); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNumber); bOperator = new JButton(/);
51、bOperator.setForeground(Color.red); bOperator.addActionListener(this); pDown.add(bOperator); bOperator = new JButton(sqrt); bOperator.addActionListener(this); bOperator.setForeground(Color.red); pDown.add(bOperator); bNumber = new JButton(4); bNumber.setForeground(Color.blue); bNumber.addActionListe
52、ner(this);21 pDown.add(bNumber); bNumber = new JButton(5); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNumber); bNumber = new JButton(6); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNumber); bOperator = new JButton(*); bOperator.s
53、etForeground(Color.red); bOperator.addActionListener(this); pDown.add(bOperator); bOperator = new JButton(x2); bOperator.setForeground(Color.red); bOperator.addActionListener(this); pDown.add(bOperator); bNumber = new JButton(1); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pD
54、own.add(bNumber); bNumber = new JButton(2); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNumber); bNumber = new JButton(3); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNumber); bOperator = new JButton(-); bOperator.setForeground(Co
55、lor.red); bOperator.addActionListener(this); pDown.add(bOperator); bOperator = new JButton(1/x); bOperator.setForeground(Color.red);22 bOperator.addActionListener(this); pDown.add(bOperator); bNumber = new JButton(0); bNumber.setForeground(Color.blue); bNumber.addActionListener(this); pDown.add(bNum
56、ber); bOperator = new JButton(+/-); bOperator.setForeground(Color.blue); bOperator.addActionListener(this); pDown.add(bOperator); bOperator = new JButton(.); bOperator.setForeground(Color.blue); bOperator.addActionListener(this); pDown.add(bOperator); bOperator = new JButton(+); bOperator.setForegro
57、und(Color.red); bOperator.addActionListener(this); pDown.add(bOperator); bOperator = new JButton(=); bOperator.setForeground(Color.red); bOperator.addActionListener(this); pDown.add(bOperator); pRight.add(pUp,BorderLayout.NORTH); pRight.add(pDown,BorderLayout.SOUTH); pBottom.add(pRight,BorderLayout.
58、EAST); contentPane.add(pBottom,BorderLayout.SOUTH); f.pack(); f.setResizable(false); f.setLocationRelativeTo(null); /f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); loginDialog(); /*登陆注册界*/ private void loginDialog() login = new JDialog();23 login.setTitle(登录); login.setLayout(
59、new FlowLayout(); login.add(new JLabel(用户名:); final JTextField name = new JTextField(10); login.add(name); login.add(new JLabel(密 码:); final JPasswordField password = new JPasswordField(10); password.setEchoChar(*); login.add(password); JButton confirm = new JButton(登录); confirm.addActionListener(ne
60、w ActionListener() public void actionPerformed(ActionEvent e) if (compareUserData(name.getText().trim(), new String(password.getPassword() login.setVisible(false); f.setVisible(true); else JOptionPane.showMessageDialog(login, 用户名或密码错误!, 错误提示, JOptionPane.ERROR_MESSAGE); ); login.add(confirm); final
61、JDialog regDialog = new JDialog(login, 注册, true); registerDialog(regDialog); JButton register = new JButton(注册); register.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) regDialog.setVisible(true); ); login.add(register); login.setSize(200, 130); login.setResizable(
62、false); login.setLocationRelativeTo(null); login.setVisible(true); /*用户名密码的确认*/ private boolean compareUserData(String name, String password) try RandomAccessFile out = new RandomAccessFile(user.dat, rw);String fname, fpassword = null;while (out.getFilePointer() 1) tResult.setText(temp.delete(temp.l
63、ength()-1, temp.length().toString();27 else tResult.setText(0); else if (s.equals(C) /如果是C删除当前计算 tResult.setText(0); tf.setText(); num1.replace(0, num1.length(), 0); num2.replace(0, num2.length(), 0); isExist = false; operate = ; else if (s.equals() tResult.setText( + Math.PI); else if (s.equals(sin
64、) String temp = tResult.getText().trim(); double dtemp = Math.PI / 180.0 * Double.parseDouble(temp); tResult.setText(+Math.sin(dtemp); save(sin + ( + temp + ) = + Math.sin(dtemp); else if (s.equals(cos) String temp = tResult.getText().trim(); double dtemp = Math.PI / 180.0 * Double.parseDouble(temp)
65、; tResult.setText(+Math.cos(dtemp); save(cos + ( + temp + ) = + Math.cos(dtemp); else if (s.equals(tan) String temp = tResult.getText().trim(); double dtemp = Math.PI / 180.0 * Double.parseDouble(temp); tResult.setText(+Math.tan(dtemp); save(tan + ( + temp + ) = + Math.tan(dtemp); else if (s.equals(
66、log) String temp = tResult.getText().trim(); double dtemp = Double.parseDouble(temp); tResult.setText(+Math.log10(dtemp); save(log + ( + temp + ) = + Math.log(dtemp); else if (s.equals(MC) /如果是MC则清除缓冲区 String temp = 0;28 memory.replace(0, memory.length(), temp); bM.setText( ); else if (s.equals(MR) /如果按键为MR则恢复缓冲区的数到文本框 tResult.setText(memory.toString(); else if (s.equals(MS) /如果按键为MS则将文本框的数存入缓冲区 String s1 = tResult.getText().trim(); memory.replace(0, memory.length(), s1); bM.setText(M); else if
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 届高考英语复习课件:专题一-名词和冠词
- 动物微生物_第八章免疫学基础理论课件
- 届高考语文一轮教学课件文言断句和翻译
- 届高考英语一轮复习考案选修7-Unit-4课件
- 槟榔的危害课件
- 动物疾病诊疗过程-兽医学概论(动物科学专业使用)课件
- 届高考英语一轮复习考案必修2-Unit-4课件
- 发动机进气系统故障课件
- 届高考英语二轮专题复习(湖南专用)阅读简答课件
- 常见酿酒葡萄品种简绍课件
- 届高考英语高效备考复习阅读理解微技能与新题型特训13课件
- 部编版小学语文二年级上册知识总结复习ppt课件全册
- 材料成形装备及自动化课件
- 届高考英语一轮复习学通语法教学课件-第-讲-动词的时态和语态-新人教版
- 厄尔尼诺和拉尼娜ppt课件