Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is what I have so far, but I don't know how to set up a sequential search for the array numbers.

  public class Assignment implements ActionListener{

        private JPanel panel;
        private JLabel label, label2;
        private JTextField text, text2;
        private JButton button, clear;
        private String[] numbers = { "5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 8080152, 4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231, 3852085, 7576651, 7881200, 4581002" };
    
    public Assignment(){
        JFrame gui = new JFrame();
        gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gui.setTitle("College Expenses");
        gui.setSize(325, 150);
        panel = new JPanel(new GridLayout(3, 2));
        gui.add(panel);
        gui.setVisible(true);
        label = new JLabel("Charge Card Number");
        label2 = new JLabel("Results");
        text = new JTextField("" , 10);
        text2 = new JTextField("" , 10);
        text2.setEditable(false);
        button = new JButton("Enter");
        clear = new JButton("Clear");
        
        panel.add(label);
        panel.add(text);
        panel.add(label2);
        panel.add(text2);
        panel.add(clear);
        clear.addActionListener(this);
        panel.add(button);
        button.addActionListener(this);
        
        }


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

    @Override
    public void actionPerformed(ActionEvent e) {
        String action = e.getActionCommand();
        if (action.equals("Clear")) {
	            text.setText("");
                    text2.setText("");
	        }
        else if (action.equals("Enter")) {
            
            
        }
            
    }
}
Posted
Updated 23-Apr-14 16:07pm
v2

1 solution

Carefull with that name "Assignment". That a common word in java programming and might be taken.

Sequencial search explained[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900