Need help with array and input
hi, I'm new to the forum and they have been of help to me before. This is my first semester of taking computer science and I'm having trouble on my 2nd to last homework assignment of the semester (its due tonight at midnight). Here are the details http://moosehead.cis.umassd.edu/cis1...k/hw5/hw5.html and here is what I have so far
Code:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.StringTokenizer;
public class InputSort extends Applet implements ActionListener
{
private Label prompt; // The GUI components
private TextArea numbers;
private TextArea sortedNumbers;
private Button up,down,clear;
private int array[];
public void init()
{
prompt = new Label("Enter a Whole Number");
numbers = new TextArea(5,40);
sortedNumbers = new TextArea(5,40);
numbers.setEditable(true);
sortedNumbers.setEditable(false);
up = new Button("Up");
down = new Button("Down");
clear = new Button("Clear");
add(prompt);
add(numbers);
add(sortedNumbers);
add(up);
add(down);
add(clear);
up.addActionListener(this);
down.addActionListener(this);
clear.addActionListener(this);
setSize(900,120);
} // init()
private void doUp()
{
// ascending sorting
}
private void doDown()
{
// descending sorting
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == clear)
{
numbers.setText("");
sortedNumbers.setText("");
return;
}
else if (e.getSource() == up)
doUp();
else if (e.getSource() == down)
doDown();
}
}
what I'm having most trouble with is getting input from user and putting it into the arrays and the StringTokenizer stuff. I think I can figure out the actual sorting of the arrays once I get the other things finished first.
Any help is appreciated, and if possible be plain and simple in your explanations because I'm still sort of new at this stuff.
Thanks in advance.
-Matt