Advertisement

01.22.2008 at 06:46PM PST, ID: 23103304
[x]
Attachment Details

Find and Sort in Array

Asked by rebelsurf86 in Java Programming Language

Tags: Java, IE7

I seem to be having a issue with getting my find feature to work properly.  Everything else seems to be working ok, but I'm not sure how to fix the find feature.  I'm sure it is something stupid, I'm just not seeing it.  Any help would be greatly appreciated.  I also need to be able to modify this to find specific number in the array and their location, which I'm unsure of how to do.  Here isn what I have so far, thanks:

import java.applet.Applet;
import java.io.*;
import java.util.*;

public class test extends Applet {
      
      public final static int ARRAY_SIZE = 2000;
      
      int find(int[ ] A) {
            
            int j;
            
            for ( j = 0; j < ARRAY_SIZE; j++ ) {
                  if (A[j] < 0) {
                        return j;
                  }
            }
      return -1;
      }      

          public static void main(String[] args){
              int[] A = new int[ARRAY_SIZE];
              for(int i = 0; i < A.length; i++){
                  A[i] = (int)Math.round(Math.random() * 99999);
                      A[0] = 39872;
                      A[1] = 51263;
                      A[2] = 132;
                      A[3] = 97832;
                      A[4] = 87213;
                      A[5] = 15236;
                      A[6] = 12345;
                      A[7] = 23778;
                      A[8] = 33333;
                      A[9] = 41424;
                      
                      
                  System.out.println("A[" + i + "] = " + A[i]);
                  
                System.out.println("First neg. interger in A is at index = " +find(A));
              }
          }
      }Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
import java.applet.Applet;
import java.io.*;
import java.util.*;
 
public class test extends Applet {
	
	public final static int ARRAY_SIZE = 2000;
	
	int find(int[ ] A) {
		
		int j;
		
		for ( j = 0; j < ARRAY_SIZE; j++ ) {
			if (A[j] < 0) {
				return j;
			}
		}
	return -1;
	}	
 
	    public static void main(String[] args){
	        int[] A = new int[ARRAY_SIZE];
	        for(int i = 0; i < A.length; i++){
	            A[i] = (int)Math.round(Math.random() * 99999);
	    		A[0] = 39872;
	    		A[1] = 51263;
	    		A[2] = 132;
	    		A[3] = 97832;
	    		A[4] = 87213;
	    		A[5] = 15236;
	    		A[6] = 12345;
	    		A[7] = 23778;
	    		A[8] = 33333;
	    		A[9] = 41424; 
	    		
	    		
	            System.out.println("A[" + i + "] = " + A[i]);
	            
    		System.out.println("First neg. interger in A is at index = " +find(A));
	        }
	    }
	}
 
 
[+][-]01.22.2008 at 07:04PM PST, ID: 20720548

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 07:10PM PST, ID: 20720570

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 07:19PM PST, ID: 20720590

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 07:24PM PST, ID: 20720606

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 07:33PM PST, ID: 20720636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 07:57PM PST, ID: 20720702

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 07:58PM PST, ID: 20720711

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 08:01PM PST, ID: 20720721

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 10:38PM PST, ID: 20721235

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 01:15AM PST, ID: 20721857

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 01:20AM PST, ID: 20721891

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 01:49AM PST, ID: 20722033

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 02:21AM PST, ID: 20722169

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 02:26AM PST, ID: 20722189

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 04:48AM PST, ID: 20722821

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 04:57AM PST, ID: 20722881

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 08:51AM PST, ID: 20724965

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 08:59AM PST, ID: 20725043

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 04:07PM PST, ID: 20729324

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:14PM PST, ID: 20747240

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:15PM PST, ID: 20747249

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:19PM PST, ID: 20747289

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:20PM PST, ID: 20747295

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:23PM PST, ID: 20747319

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:25PM PST, ID: 20747326

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 03:41PM PST, ID: 20747403

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 04:15PM PST, ID: 20747591

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.25.2008 at 04:24PM PST, ID: 20747638

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.26.2008 at 02:57AM PST, ID: 20749154

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.26.2008 at 03:07AM PST, ID: 20749168

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: Java, IE7
Sign Up Now!
Solution Provided By: ragerino
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628