各位好 我在网路上实在找不到我的相关问题 所以我想请教各位一下>"<
我的作业是要做一个类似计算机的面盘
他要输入学生成绩 输入完后按+(成绩相加)
直到全部输入完后按#
而每个学生的成绩会在分类
如A=90~99
B=80~89
.
.
.
F=01~49
下面的TextArea会出现
一共有" "个学生 总成绩为" " 平均成绩为" "
及A~F的学生各是几个
我现在只会做到成绩彼此相加....ˊ ˋ
我实在是不知道怎么在相加间并记算一共有几个学生
但这样便无法只道平均成绩以及A~F的分类了......
以下是我做的部分 可以帮我看一下吗?
// Tutorial 10: InterestCalculator.java
// Calculate the total value of an investment.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.Date;
public class FutureValueCalculator_OK extends JFrame
{
// JLabel and JTextField for user to input security code
private JLabel studentgradeJLabel;
private JTextField studentgradeJTextField;
// JButtons to represent security keypad
// JButtons to represent security keypad
private JButton oneJButton;
private JButton twoJButton;
private JButton threeJButton;
private JButton fourJButton;
private JButton fiveJButton;
private JButton sixJButton;
private JButton sevenJButton;
private JButton eightJButton;
private JButton nineJButton;
private JButton clearJButton;
private JButton zeroJButton;
private JButton enterJButton;
private JButton plusJButton;
private JButton multiplyJButton;
private JButton divideJButton;
// JLabel, JTextArea and JScrollPane to display access log
private JLabel accessLogJLabel;
private JTextArea accessLogJTextArea;
private JScrollPane accessLogJScrollPane;
private int total;
private int student;
private static String customer;
// no-argument constructor
public FutureValueCalculator_OK(String name)
{
customer=name;
createUserInterface();
}
private void createUserInterface()
{
// get content pane for attaching GUI components
Container contentPane = getContentPane();
// enable explicit positioning of GUI components
contentPane.setLayout( null );
// set up securityCodeJLabel
studentgradeJLabel = new JLabel();
studentgradeJLabel.setBounds( 16, 16, 90, 21 );
studentgradeJLabel.setText( "Student grade:" );
contentPane.add( studentgradeJLabel );
// set up securityCodeJTextField
studentgradeJTextField = new JTextField();
studentgradeJTextField.setBounds( 114, 16, 172, 26 );
studentgradeJTextField.setEditable( false );
contentPane.add( studentgradeJTextField );
// set up oneJButton
oneJButton = new JButton();
oneJButton.setBounds( 80, 64, 50, 50 );
oneJButton.setText( "1" );
contentPane.add( oneJButton );
oneJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when oneJButton is pressed
public void actionPerformed( ActionEvent event )
{
oneJButtonActionPerformed( event );
}
} // end anonymous inner class
); // end call to addActionListener
// set up twoJButton
twoJButton = new JButton();
twoJButton.setBounds( 130, 64, 50, 50 );
twoJButton.setText( "2" );
contentPane.add( twoJButton );
twoJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when twoJButton is pressed
public void actionPerformed( ActionEvent event )
{
twoJButtonActionPerformed( event );
}
} // end anonymous inner class
); // end call to addActionListener
// set up threeJButton
threeJButton = new JButton();
threeJButton.setBounds( 180, 64, 50, 50 );
threeJButton.setText( "3" );
contentPane.add( threeJButton );
threeJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when threeJButton is pressed
public void actionPerformed( ActionEvent event )
{
threeJButtonActionPerformed( event );
}
} // end anonymous inner class
); // end call to addActionListener
// set up fourJButton
fourJButton = new JButton();
fourJButton.setBounds( 80, 114, 50, 50 );
fourJButton.setText( "4" );
contentPane.add( fourJButton );
fourJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when fourJButton is pressed
public void actionPerformed( ActionEvent event )
{
fourJButtonActionPerformed( event );
}
} // end anonymous inner class
); // end call to addActionListener
// set up fiveJButton
fiveJButton = new JButton();
fiveJButton.setBounds( 130, 114, 50, 50 );
fiveJButton.setText( "5" );
contentPane.add( fiveJButton );
fiveJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when fiveJButton ..
访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容