The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Java

Posted by Nicolas Krim on November 23, 2000 at 9:37 AM

Dear Mr Kishori,
As I am doing my coursework in java, I was asked to do the following :

This coursework exercise is worth 30% of the marks for module IM205;
the exam is worth 70%. The coursework must be handed in to the
Assessments Unit by 25 November 2000.

You should hand in a printout of your source code, together with a
description of the test cases used to test each method, and your
source code on a floppy disk. Each method should be preceded by a
comment explaining what it does and how, and listing any assumptions
made in its construction.

The marking criteria will include

- adherence to the specification
- simplicity/ clarity of the code
- clear, sensible documentation (comments)
- well chosen test cases

The Exercise:

1) Write a method first to return the first word in a list of
characters that represents a sentence Note: you may assume that words
consist only of lower case letters of the alphabet, and that words
are separated by one or more space characters. There may also be
leading spaces. For example:

first(" patriotism is the last refuge of a scoundrel")
= "patriotism"

2) Write a method breakUp to convert a list of characters that
represents a sentence into a list of words (ie. a list of lists of
characters). Note: as above, you may assume that words consist only
of lower case letters of the alphabet, and that words are separated
by one or more space characters.

breakUp (" patriotism is the last refuge of a scoundrel")
= ["patriotism","is","the","last","refuge","of","a","scoundrel"]


3) Write a method wordSort to sort a list of words as above into
either dictionary order or by length of word, dependent upon the
value of a parameter to the method.

4) Write a method rebuild, the opposite of breakUp, to convert a
list of lists of characters as above into a list of characters
representing the original sentence, but with the words separated
by precisely one space ie.

rebuild (["patriotism","is","the","last","refuge","of","a","scoundrel"])
= ("patriotism is the last refuge of a scoundrel")

5) Write a suitable main method to test the above methods by
reading a sentence, and writing it out again once with the words
in dictionary order, and once with the words in order of length,
in each case with only one space between each word.


Can you please email me the answer for the above questions that would be greatfull as it is your line of work ...
Many thanks
Nicolas Krim





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us