Results 1 to 5 of 5
  1. #1
    worsethenu is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default problems with counting

    Hello all, Im very new to java and hope someone can help. I have a file with 150 entries consisting of 100 different numbers. I want to print out the 5 numbers that appear the fewest times. I have built a loop and can read the file, but i don't know how to handle the variables while i do the counting? any help is greatly appreciated.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default

    How would you do this "by hand"? If you were given a stack of 150 index cards, each with a number from 1-100 written on it, how would you count the number that appeared the most often?

  3. #3
    worsethenu is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    I guess i'd build piles and then count them, but if i do that here won't i need to declare 100 different variables?

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default

    Quote Originally Posted by worsethenu View Post
    I guess i'd build piles and then count them, but if i do that here won't i need to declare 100 different variables?
    Or you could use an array or a List...

  5. #5
    worsethenu is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    Thanks kevin. I'm gonna go read the chapter on arrays. I'm only 5 chapters into this book and it hasn't covered them thus far.

Similar Threads

  1. Counting numbers up and down
    By radio in forum New To Java
    Replies: 4
    Last Post: 05-06-2011, 04:03 PM
  2. Counting help
    By jksmithson in forum New To Java
    Replies: 1
    Last Post: 11-06-2009, 03:43 AM
  3. Counting characters
    By Tiff89 in forum New To Java
    Replies: 10
    Last Post: 12-12-2008, 10:21 AM
  4. Need help with counting letters
    By mrdestroy in forum New To Java
    Replies: 15
    Last Post: 10-22-2008, 02:33 PM
  5. Counting Pixels
    By shaungoater in forum Java 2D
    Replies: 5
    Last Post: 11-29-2007, 06:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •