当前位置:首页 » 大中小学 » 合肥工业大学java程序设计报告

合肥工业大学java程序设计报告

发布时间: 2021-09-14 20:30:35

1、JAVA语言程序设计实验报告

?

2、蚌埠学院java程序设计实验报告

一般这种报告,都有固定的形式,问问你们额班长或者学长,他们应该有模板的

3、求java程序设计报告~(很急哦!明天就要了!)

类图就是要你把每个类的关系用图形表示出来,
这是我以前做项目的时候写的
不知道能不能帮助你!
设计概要就更简单了
就是要吧每个类的属性和方法写(列)出来,以及其功能,作用
这些东西应该是你在编码之前就该做的事情,
能帮助你理清思路,完成编码;
既然你现在代码都写好了
还要这个干吗!

4、求一份JAVA计算机程序设计报告

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.*;
import javax.swing.border.*;
import java.util.*;

@SuppressWarnings("serial")
public class ComputerPad extends JFrame
implements ActionListener
{
private NumberButton[] numberButton;
private OperationButton[] operationButton;
private JButton dotButton;
private JButton signButton;
private JButton backspaceButton;
private JButton reciprocalButton;
private JButton equalButton;
private JButton clearZeroButton;

JPanel panel;
JTextField resultShow;
operationButton = new OperationButton[4];
operationButton[0] = new OperationButton("+");
operationButton[1] = new OperationButton("-");
operationButton[2] = new OperationButton("*");
operationButton[3] = new OperationButton("/");

LinkedList<String> dataList;
// 等号进行默认设置
boolean equalButtonIsPressed = false;

public ComputerPad(){
super("yuelou计算器");
dataList = new LinkedList<String>();
numberButton = new NumberButton[10];

for(int i = 0; i <= 9; i++){
numberButton[i] = new NumberButton(i);
numberButton[i].addActionListener(this);
}

operationButton = new OperationButton[4];

for(int i = 0;i < 4; i++){
operationButton[i] = new OperationButton(operators[i]);
operationButton[i].addActionListener(this);
}
//符号进行初始设置
dotButton = new JButton(".");
signButton = new JButton("+/-");
equalButton = new JButton("=");
reciprocalButton = new JButton("1/x");
backspaceButton = new JButton("退格");
clearZeroButton = new JButton("AC");
//设置颜色
clearZeroButton.setForeground(Color.red);
backspaceButton.setForeground(Color.red);
reciprocalButton.setForeground(Color.red);

equalButton.setForeground(Color.blue);
signButton.setForeground(Color.blue);
dotButton.setForeground(Color.blue);

clearZeroButton.addActionListener(this);
backspaceButton.addActionListener(this);
reciprocalButton.addActionListener(this);

equalButton.addActionListener(this);
signButton.addActionListener(this);
dotButton.addActionListener(this);

resultShow = new JTextField(10);
resultShow.setHorizontalAlignment(JTextField.RIGHT);
resultShow.setForeground(Color.blue);
resultShow.setFont(new Font("TimesRoman", Font.PLAIN, 15));
resultShow.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
resultShow.setBackground(Color.white);
resultShow.setEditable(false);

panel = new JPanel();
// 设置四行五列
panel.setLayout(new GridLayout(4,5));
//面板中的第一行
for(int i = 1; i < 4; i++)
{
p.add(numberButton[i]);
}

p.add(operationButton[0]);
p.add(clearButton);

//面板中的第2行
for(int i = 4; i < 7; i++)
{
p.add(numberButton[i]);
}
p.add(operationButton[1]);
p.add(bkspaceButton)

//面板中的第3行
for(int i = 7; i < 10; i++)
{
p.add(numberButton[i]);
}
p.add(operationButton[2]);
p.add(reciprocalButton);

//面板中的第4行
p.add(numberButton[0]);
p.add(signButton);
p.add(dotButton);
p.add(operationButton[3]);
p.add(equalButton);

add(panel, BorderLayout.CENTER);
add(resultShow, BorderLayout.NORTH);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setBounds(100, 50, 340, 180);
setResizable(false);
validate();

}

public void actionPerformed(ActionEvent e) {

//如果按下的是“数字按钮”
if(e.getSource() instanceof NumberButton){
NumberButton b = (NumberButton)e.getSource();
//字符串中没有字符时
if(dataList.size() == 0){
int number = b.getNumber();
dataList.add("" + number);
resultShow.setText("" + number);
equalButtonIsPressed = false;
}
//字符串中有一个字符时,并且在此时没有按过等号
else if(dataList.size() == 1 && equalButtonIsPressed == false){
int number = b.getNumber();
String num = (String)dataList.getFirst();
String s = num.concat("" + number);
//把S放在字符串的第一个位置,下标为零
dataList.set(0, s);
//把S输出到窗口
resultShow.setText(s);
}//字符串中有一个字符时,并且在此时按过等号
else if(dataList.size() == 1 && equalButtonIsPressed == true){
int number = b.getNumber();
//把字符串中的第一个移出
dataList.removeFirst();
dataList.add("" + number);
equalButtonIsPressed = false;
resultShow.setText("" + number);
}
else if(dataList.size() == 2){
int number = b.getNumber();
dataList.add("" + number);
resultShow.setText("" + number);
}else if(dataList.size() == 3){
int number = b.getNumber();
String num = (String)dataList.getLast();
String s = num.concat("" + number);
dataList.set(2, s);
resultShow.setText(s);
}
}

//如果按下的是“各种操作符按钮”
else if(e.getSource() instanceof OperationButton){
OperationButton b = (OperationButton)e.getSource();
if(dataList.size() == 1){
String fuhao = b.getOperator();

dataList.add(fuhao);
}
else if(dataList.size() == 2){
String fuhao = b.getOperator();

dataList.set(1, fuhao);
}
else if(dataList.size() == 3){
String fuhao = b.getOperator();
String number1 = (String)dataList.getFirst();
String number2 = (String)dataList.getLast();
// 对加减乘除进行符号提取
String operator = (String)dataList.get(1);

// 对加减乘除进行符号提取

double n1 = Double.parseDouble(number1);
double n2 = Double.parseDouble(number2);
//对数据进行初始化设置
double n = 0;
//进行运算
if(operator.equals("+")){
n = n1 + n2;
}
else if(operator.equals("-")){
n = n1 - n2;
}
else if(operator.equals("*")){
n = n1 * n2;
}
else if(operator.equals("/")){
n = n1 / n2;
}
// 输出接果 并对输入的字符串进行输入
dataList.clear();
dataList.add("" + n);
dataList.add(fuhao);
resultShow.setText("" + n);

}
}

//如果按下的是“等号按钮”
else if(e.getSource() == equalButton){
equalButtonIsPressed = true;
//链表内有两个字符串时
if(dataList.size() == 2)
{
// 对加减乘除进行符号提取(详细注释同上)
String operator =
(String)dataList.get(1);
String num1 =
(String)dataList.getFirst();
double n1 =
Double.parseDouble(num1);
double n = 0;

if(operator.equals("+"))
{
n = n1 + n1;
}
else if(operator.equals("-"))
{
n = n1 - n1;
}
else if(operator.equals("*"))
{
n = n1 * n1;
}
else if(operator.equals("/"))
{
n = n1 / n1;
}
//清理链表
dataList.clear();
dataList.add("" + n);
resultShow.setText(""+n);
}
//链表内有三个字符串时
else if(dataList.size() == 3)
{
String number1 = (String)dataList.getFirst();
String number2 = (String)dataList.getLast();
String operator = (String)dataList.get(1);

double n1 = Double.parseDouble(number1);
double n2 = Double.parseDouble(number2);
double n = 0;

if(operator.equals("+")){
n = n1 + n2;
}
else if(operator.equals("-")){
n = n1 - n2;
}
else if(operator.equals("*")){
n = n1 * n2;
}
else if(operator.equals("/")){
n = n1 / n2;
}

dataList.clear();
dataList.add("" + n);
resultShow.setText("" + n);

}
}

//如果按下的是“小数点按钮”
else if(e.getSource() == dotButton){
if(dataList.size() == 0)
{
//默认输出“0.”
dataList.add("0.");
}
else if(dataList.size() == 1)
{
String num1 = dataList.getFirst();
//判断以前是否有过输入小数点,为-1时为没有加点
if(num1.indexOf('.') == -1)
{
String s = num1.concat(".");
dataList.set(0,s);
}
}
else if(dataList.size() == 2)
{
dataList.add("0.");
}
else if(dataList.size() == 3)
{
String num2 = dataList.getLast();
if(num2.indexOf('.') == -1)
{
String s = num2.concat(".");
dataList.set(2,s);
}
}

}

//如果按下的是“退格按钮”
else if(e.getSource() == backspaceButton){
if(dataList.size() == 1)
{
String num1 = dataList.getFirst();
String s ;
if(num1.length() > 1)
{
//截取字符串中的子串
s = num1.substring(0,num1.length()-1);
}
else
{
s = "0";
}

dataList.set(0,""+s);
resultShow.setText(s);
}
else if(dataList.size() == 3)
{
String num2 = dataList.getLast();
String s ;

if(num2.length() > 1)
{
s = num2.substring(0,num2.length()-1);
}
else
{
s = "0";
}
dataList.set(2,""+s);
resultShow.setText(s);
}
}

//如果按下的是“正负号按钮”
else if(e.getSource() == signButton){
if(dataList.size() == 1)
{
String num1 = dataList.getFirst();
double n1 = Double.parseDouble(num1);
n1 = -1 * n1;

dataList.set(0,""+n1);
resultShow.setText(""+n1);
}
else if(dataList.size() == 3)
{
String num2 = dataList.getLast();
double n2 = Double.parseDouble(num2);
n2 = -1 * n2;

dataList.set(2,""+n2);
resultShow.setText(""+n2);
}

}

//如果按下的是“倒数按钮”
else if(e.getSource() == reciprocalButton){
if(dataList.size() == 1)
{
String num1 = dataList.getFirst();
double n1 = Double.parseDouble(num1);
n1 = 1 / n1;

dataList.set(0,""+n1);
resultShow.setText(""+n1);
}
else if(dataList.size() == 3)
{
String num2 = dataList.getLast();
double n2 = Double.parseDouble(num2);
n2 = 1 / n2;

dataList.set(2,""+n2);
resultShow.setText(""+n2);
}
}

//如果按下的是“清零按钮”
else if(e.getSource() == clearZeroButton){
dataList.clear();
resultShow.setText("0");
}
}

public static void main(String[] args){
new ComputerPad();
}
}

这是主类 ~你建立一个类
还有两个分类

我在发给你
记得把我的名字该你的就可以拉

import javax.swing.*;
import java.awt.*;

public class NumberButton
extends JButton
{
private int number;

NumberButton(int number)
{
super("" + number);
this.number = number;
setForeground(Color.blue);
setFont(new Font("Serif", Font.BOLD,15));
}

public int getNumber()
{
return number;
}

}

///////////

import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;

public class OperationButton
extends JButton
{
private String operator;

OperationButton(String operator)
{
super(operator);
this.operator = operator;
setForeground(Color.RED);
setFont(new Font("Serif", Font.BOLD,15));
}

public String getOperator()
{
return operator;
}
}

5、java程序设计报告总体设计怎么写

写出用了哪些变量、哪些函数、

程序结构及结构图、写出源代码、程序运行截图就OK了

热点内容
合肥瑶海区招投标中心 发布:2020-09-09 14:35:50 浏览:505
合肥长城宽带价格表 发布:2020-09-09 02:57:42 浏览:505
合肥小区名称 发布:2020-09-10 05:51:24 浏览:504
365房产合肥 发布:2020-09-09 22:32:45 浏览:504
成都大巴包车 发布:2020-09-09 21:03:12 浏览:504
合肥万达城摩天轮营业 发布:2020-09-10 08:43:47 浏览:503
上海合肥高铁 发布:2020-09-09 20:23:53 浏览:503
合肥立特科技 发布:2020-09-09 16:27:05 浏览:503
合肥徽昌苑二手房 发布:2020-09-09 03:48:06 浏览:503
杭州到合肥高铁时刻表查询 发布:2020-09-17 08:24:49 浏览:502