Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:55:01+00:00 2026-06-13T03:55:01+00:00

I have to pass two arrays 1) that are filled with 1000 int’s between

  • 0

I have to pass two arrays
1) that are filled with 1000 int’s between 0-100
2) that contains ten bins to sort the 1000 numbers.

How do I create the counter to sort numbers into ten bins such as 0-9, 10-19, 20-29, 30-39, 40-49,50-59 and so on to 90-99…

Would it be with an if/else that sorts them? If so, how do I add values into each bin? Would it be something like this?

This is what I have so far:

          //initialize array of 1000 elements
          int[] numbers = new int[1000];
          int i = 0;
          //initialize array of 10 bins
          int[] bins = new int[10];

          void setup() {
              // Populate array with random number
              for (int i = 0; i < numbers.length; i++) {
                 numbers[i] = ceil(random(0,99));
              }

           }

           //function that sorts random numbers into bins
           void counter(int[] numbers, int[] bins) {

           }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:55:03+00:00Added an answer on June 13, 2026 at 3:55 am

    If you want every number from numbers in the right bin then I would use an array of 10 ArrayLists as the datastructure for your bins.

    int[] numbers = new int[1000];
    ArrayList[] bins = new ArrayList[10];
    
    void setup() {
        for(int i = 0; i<bins.length; i++) {
            bins[i] = new ArrayList();
        }
    
        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = floor(random(0,100));
        }
    }
    
    void counter(int[] numbers, ArrayList[] bins) {
        for (int i = 0; i < numbers.length; i++) {
            bins[floor(float(numbers[i])/10.0)].add(numbers[i]);
        }
    }
    

    You then get a bin with (for example the first bin consisting of numbers with values 0-9):

    int sizeBin = bins[0].size();
    for(int i=0; i<sizeBin; i++) {
        println(bins[0].get(i));
    }
    

    If you want the count of numbers in a bin you can get it with (again an example with the bin 0-9)

    bins[0].size();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Java netty servers that need to pass lots of messages between
I have two ListActivity classes that I want to pass into into a third
I have an array filled with instances of a custom class which contains two
I have a situation where I need to pass two parameters to an action.
The problem I have is to pass the chained search of two models to
I have two pages and I want to pass data to each other. How
i have two flex applications and i want to pass the data from one
I Have two problem in this Case : I want to pass a JSON
I have a situation where I have two arrays and I use one array(A)
I have some problems using two dimensional array. static const int PATTERNS[20][4]; static void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.