reading,sorting,displaying data from a text file

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: reading,sorting,displaying data from a text file

  1. #1
    Join Date
    Jan 2005

    Unhappy reading,sorting,displaying data from a text file

    How do i accomplish the task below using java. Please include code.

    Consider a text file which contains a minimum of 20 english sentences one per line. You are required to write a program which will list the first three words which have the highest frequency of use and the three words with the lowest frequency of use. eg. if the words in a text file had the following frequency of use as shown below

    Time table - 4
    security - 2
    projector - 3
    monday - 10
    morning - 7
    classroom - 5
    cleaner - 6
    director - 1
    lecturer - 2
    evening - 8

    the program should produce an output such as:
    Words with highest frequency of use:

    monday 10
    evening 8
    morning 7

    Words with the lowest frequency of use:

    director 1
    lecturer 2
    security 2

    note: the words with the same frequency of use are listed in alphabetical order. Assume that all the words in the text file are in lower case and are seperated by one or more spaces.

  2. #2
    Join Date
    Feb 2004
    Maybe if you offer money someone will do it all for you, but you won't learn anything. As I said in the other post, tell us specifically what it is you're having trouble with and someone will help.

  3. #3
    Join Date
    Nov 2004
    Check out the static method Collections.sort() and
    the Comparable interface.\, and
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center