0

Given a bunch of temperatures, I am supposed to put them into an array that sorts them by every 10 degrees. I am pretty confused. I was able to print out all the temperatures from a provided txt file, but now I am not sure how to put them into an array. There should be 11 indexes( <=9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-89, 90-99, and >=100). I am just really confused on how to use arrays.

3
  • that seems like homework that you are not willing to put some effort in ;) Commented Mar 26, 2012 at 22:26
  • The Java Tutorial is your friend. Commented Mar 26, 2012 at 22:28
  • No no no, there is much more to the program than this, and I can do the rest if I can just figure this part out. I spent 4 hours today trying and I'm hopeless. Commented Mar 26, 2012 at 22:28

2 Answers 2

1

I think you should use multidimensional array or a hash table that sort temperatures in a range from 1 to 10 and from 10 to 20

Sign up to request clarification or add additional context in comments.

Comments

0

Put to the array the upper edges:

int[] a = {10, 20, 30, ..., Integer.MAX_INTEGER}

It defines intervals 0-9, 10-19, etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.