Cannot figure out min and max, without using arrays. if possible.
here is my code. it is due at midnight tonight. i have been working on this final part for a long time PLEASE, PLEASE HELP
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
public class TestScores
{
public static void main(String args[])
{
//create an instance of the JFrame
JFrame frame = new TestScoresFrame();
//make the JFrame visible
frame.setVisible(true);
}//end main()
}//end FutureValueFrameApp class
class TestScoresFrame extends JFrame
{
//the FutureValueFrame() constructor sets the properties for the frame...must have the same name as the class and must be public and there is no rturn datatype
public TestScoresFrame()
{
setTitle("Encore Movies");
setSize(250, 210);
setResizable(false);
//another way to center the app
//setLocationRelativeTo(null);
centerWindow(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new TestScoresPanel();
add(panel);
}//end FutureValueFrame() constuctor
private void centerWindow(Window w)
{
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
setLocation((d.width - w.getWidth()) / 2, (d.height - w.getHeight()) /2);
}//end centerWindow()
}// end FutureValueFrame class
class TestScoresPanel extends JPanel implements ActionListener
{
//declare variables
private JButton calculateButton, resetButton, exitButton;
private JTextField scoreField, numberField, averageField, bestField, worstField;
private JLabel scoreLabel, numberLabel, averageLabel, bestLabel, worstLabel;
int i = 0;
double total = 0;
double scores = 0;
double average = 0;
public TestScoresPanel()
{
//set the latour for the panel
setLayout(new BorderLayout());
//display panel
JPanel displayPanel = new JPanel();
displayPanel.setLayout (new FlowLayout(FlowLayout.CENTER));
scoreLabel = new JLabel("Enter Score: ");
displayPanel.add(scoreLabel);
scoreField = new JTextField(10);
displayPanel.add(scoreField);
numberLabel = new JLabel("Number of Scores: ");
displayPanel.add(numberLabel);
numberField = new JTextField(10);
numberField.setEditable(false);
numberField.setFocusable(false);
displayPanel.add(numberField);
averageLabel = new JLabel("Average Score: ");
displayPanel.add(averageLabel);
averageField = new JTextField(10);
averageField.setEditable(false);
averageField.setFocusable(false);
displayPanel.add(averageField);
bestLabel = new JLabel("Best Score: ");
displayPanel.add(bestLabel);
bestField = new JTextField(10);
bestField.setEditable(false);
bestField.setFocusable(false);
displayPanel.add(bestField);
worstLabel = new JLabel("Worst Score: ");
displayPanel.add(worstLabel);
worstField = new JTextField(10);
worstField.setEditable(false);
worstField.setFocusable(false);
displayPanel.add(worstField);
//button panel
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
calculateButton = new JButton("Enter Score:");
calculateButton.addActionListener(this);
buttonPanel.add(calculateButton);
resetButton = new JButton("Reset");
resetButton.addActionListener(this);
buttonPanel.add(resetButton);
exitButton = new JButton("Exit");
exitButton.addActionListener(this);
buttonPanel.add(exitButton);
//add panels to the main panel
add(buttonPanel, BorderLayout.SOUTH);
add(displayPanel,BorderLayout.CENTER);
}//end FutureValuePanel() constructor
//actionPerformed() is excecuted every time the user clicks one of the buttons,...this tells the buttons what to do
public void actionPerformed(ActionEvent e)
{
//determined what was clicked
Object source = e.getSource();
if(source == exitButton)
System.exit(0);
else if(source == calculateButton)
{
int scores = Integer.parseInt(scoreField.getText());
i += 1;
total += scores;
double average = total / i;
String averageString = Double.toString(average);
String iString = Integer.toString(i);
averageField.setText(averageString);
numberField.setText(iString);
scoreField.requestFocus();
scoreField.selectAll();
}//end else if
else if(source == resetButton)
{
double average = 0;
i = 0;
total = 0;
scoreField.setText("");
numberField.setText("");
averageField.setText("");
bestField.setText("");
worstField.setText("");
scoreField.requestFocus();
}//end else if
}//end actionPerformed()
}//end FutureValuePanel class