Display 100 random integers in [10, 25]
14 14 18 24 12 25 16 12 18 16
15 16 16 15 17 19 10 21 14 25
21 24 10 19 25 17 19 13 25 24
23 25 15 25 18 23 18 14 24 11
21 12 20 24 14 18 11 12 14 13
14 20 11 16 21 15 15 17 20 24
10 18 20 18 24 23 17 18 15 11
20 19 14 23 20 23 18 22 20 11
10 24 22 12 10 11 11 12 12 13
14 12 15 15 13 24 23 23 11 23
*************************************************
Display occurrences
10: 5
11: 8
12: 8
13: 4
14: 9
15: 8
16: 5
17: 4
18: 9
19: 4
20: 7
21: 4
22: 2
23: 8
24: 9
25: 6
Max occurrences: 9
Min occurrences: 2
Average occurrences: 6.25

here is my code rite now:

  public int[]Occur(int[]Array){



public int[]Occur(int[]Array){

       int[]countA= new int[35];
       for(int i=0;i<Array.length;i++){
           countA[Array[i]]++;
       }
       return countA; 
    }

   public void displayOccur(int[]countA,int[]Array){
       System.out.println("Display Occurrences :");
       int num;
       for (int i=10;i<=25;i++){

         num=+countA[i];
           System.out.println(i+": "+ countA[num]);
 }

what's wrong with it???/can u help me

the counting looks ok, but when you print I don't understand why you do that stuff with "num". countA[i] contains the count for value i, so why not just print that?

ok.but when i print it didn't print the occurrences of number..it just prints 100 or 0...weird==

Here's a quick way to print a whole array in one line...
System.out.println(java.util.Arrays.toString(myArray));
so use that inside your counting loop (lines 8-10 above) to see what's really happening there.

(Obviously you have to replace "myArray" with the name of your array that you want to print!)

but i need the full code for this exercise==..that's the point==...i'm tired of that

Are you asking for someone to post the full solution for you?

nope.just a little bit code for displays the time occurences of each num. that's all

That sounds like the whole thing to me! Nobody's going to do your homework for you, so the best thing is to get on with debugging your own code, as I suggested a couple of posts ago - ie find out whether its the calculation of the occurrences or the porinting that's worong.

it's just a piece of my hw.i couldnt find any solution to display the occur like that..that's really complicated==

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.