Help on some java questions
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Help on some java questions

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Exclamation Help on some java questions

    Been finding it hard to get anywhere with these questions wandering if anybody could help me out a little bit. Any help would be much appreciated.


    You are provided with a List<String> of words. Each word in the list can occur more than once.

    a) Write the method
    String findWord(List<String> words, String s)

    which returns true if s is in the list or false otherwise. For full marks the method should ignore the case, so that sNAke = snake for example. [3 marks] [easy]


    b) Write the method
    String findLastWord(List<String> words)

    which returns the word that appears last, if sorted alphabetically. Remember Collections.Sort(.....) will sort a list. [3 marks] [easy]


    c) Write the method
    int getAverageLength (List<String> words)

    which returns the average length of all the words in the list. For example, if the list contained {the, cat, snake, zebra} the answer would be 4. For full marks you must round the average to the nearest character. [6 marks] [moderate]


    d) Write the method
    String findMostCommonWord(List<String> words)

    which returns the word that appears most often in the list. For full marks it should ignore case, so SnAKE and snake and SNAKE all count as the same word. [8 marks] [moderate]


    e) Write the method
    ArrayList<String> sortByLength(List<String> words)

    which returns an arraylist of the words in the original list, but sorted by length from lowest to highest.

    For example - if the list was {dog, tree, cake, beggar, cheese, a}

    the resulting arraylist would be {a, dog, tree, cake, cheese, beggar}

    If two words have the same number of letters, just place them next to each other in the list as shown above.
    [15 marks] [difficult

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Help on some java questions

    Post up the code you've got so far, and explain exactly where you're stuck, or what you don't understand, and we may be able to help.

    I for one am not going to do it for you.

    Teachers open the door, but you must enter by yourself...
    Chinese proverb
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    May 2009
    Location
    Surrey, UK
    Posts
    285

    Re: Help on some java questions

    Just something to amuse your classmates and embarrass your teacher:
    Quote Originally Posted by johnnywishwash View Post
    a) Write the method
    String findWord(List<String> words, String s)

    which returns true if s is in the list or false otherwise.
    A method with that signature should return a String, not a boolean...

  4. #4
    Join Date
    Apr 2007
    Posts
    425

    Re: Help on some java questions

    well, if you offer dollars for marks maybe people will do it for you. Otherwise show that you're trying.

    P.S. how deep is your wallet? The next assignment will be harder.
    ------
    If you are satisfied with the responses, add to the user's rep!

  5. #5
    Join Date
    May 2009
    Posts
    2,413

    Re: Help on some java questions

    Quote Originally Posted by johnnywishwash View Post
    Been finding it hard to get anywhere with these questions wandering if anybody could help me out a little bit. Any help would be much appreciated.
    Publishing homework on the internet is a sign of distress. My best advice is that you team up with a fellow student as soon as possible. You cannot go it alone.

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center