-
August 14th, 2009, 01:44 PM
#1
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
-
August 14th, 2009, 03:52 PM
#2
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 [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
August 14th, 2009, 04:26 PM
#3
Re: Help on some java questions
Just something to amuse your classmates and embarrass your teacher:
Originally Posted by johnnywishwash
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...
-
August 15th, 2009, 12:29 PM
#4
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!
-
August 15th, 2009, 06:44 PM
#5
Re: Help on some java questions
Originally Posted by johnnywishwash
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|