各位好 我在網路上實在找不到我的相關問題 所以我想請教各位一下>"<
我的作業是要做一個類似計算機的面盤
他要輸入學生成績 輸入完後按+(成績相加)
直到全部輸入完後按#
而每個學生的成績會在分類
如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 可以看到全部內容