Bookmark Topic Watch Topic
  • New Topic

Confused  RSS feed

 
conner Statham
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
v
 
Chris Barrett
Bartender
Posts: 321
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Conner,

Looks like you have successfully read the data file into the array. What do you think the next step is? Which method will you tackle first and how will you iterate the array to accomplish this?

If you are not sure, I suggest you spend some time with pen and paper working out how you would do this with real world objects. If I give you a bunch of numbers from 1 - 10, and you then place those numbers in ten corresponding boxes labelled 1 - 10, what do you need to do to tell me which box has the most numbers, or what the average quantity of numbers is in each box? Break those problems down into separate solutions, which will make the basis of your methods. Figuring out this logic is often the hardest part of any project, and doing this yourself in the long term will be much more beneficial to your development then spending time looking for other peoples' coding solutions.

Regarding methods, I notice the instructions indicated "you should also have a method to read and tabulate the array.". Why are you doing that in your main method? Better to keep your main method really small and use it to just call the individual methods required to accomplish the tasks.

Cheers!
Chris
 
Mark Doucette
Greenhorn
Posts: 5
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Conner,

As Chris said, you are on the right track so just try to work through the next steps.

Just a couple of quick points:

1. When declaring and initializing an array using int[] count = new int[arraySize]; the values are already set to the default value for the data type (int's are defaulted to 0) so there is no need to populate the array using a for loop, unless you are wanting to put non default values in there.

2. You for loop in the printCounts method should start at int i = 1. Right now you are skipping the first 2 elements of the array and starting at the 3rd element (because arrays are zero based). So you are missing [1] 220 in your output.


Take care
Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!