我有个简单的JAVA作业,可是我不会,能不能帮我一下,万分感谢啊!!
下面是题目,英文的,汗。。。
The programming task
You are to write a Java application program named AssigOne108.java which provides the user with
output in the form of an abbreviated form of a String or sentence they have entered. The details
(specifications) of this task are given below. Note that the correctness marks you receive for your program
will depend on how well it matches this specification. If you decide to implement something that is more
elaborate than specified, you should understand that:
There will be no marks awarded for the elaborations you have designed and penalties may be
applied for confusing/extraneous code.
Your program MUST STILL meet the basic specifications given below.
The program is to implement the following simple sentence abbreviation algorithm:
The String (of a single, or multiple words) they wish to have abbreviated is input
All single character words remain in the output String
All vowels (a, e, i , o ,u), that are not single character words, are dropped from the output String
All double letter consonants (any letters that are not vowels) are reduced to a single for the output
String. i.e 'nn' becomes 'n'.
Punctuation, including spaces, remain in the String, along with numerical values (0-9)
When the output has been generated the result will be displayed on the screen.
The output string will then be examined to produce more output:
Output the integer value of the number of characters shorter the output String is than the input
String.
Examine the output String, discovering the number of words in the String and then output this value
along with the average number of letters removed from each word over the sentence.
The user will be able to run the program multiple times abbreviating many sentances
NOTE: Part of the assessment of your program may be done automatically, so it is important that you
follow the specification exactly for example the method the user is given to indicate that they want to
abbreviate another String must be as specified.
Details
The user will be asked to enter a String of single or multiple words in length. (Their entry may
contain spaces, digits, and/or punctuation characters.)
The program will then work out the modified version of the user's String as follows.
Starting with an empty output String the input String is examined one character at a time,
keeping track of the previous characters value:
If the character is a number or punctuation character then
it is copied to the output string
Otherwise
If the character matches the previous character then it is dropped from the
output string
Otherwise
If the character is a vowel (a, e, i, o, u) and not a single character word
then
The letter is dropped from the output string
Otherwise the letter is copied to the output string
file:///C:/Documents%20and%20Settings/jdscanla/Desktop/assig1.html
2 of 7 29/09/2009 1:05 PM
The output String is then displayed on the screen
Statistics about the String are then displayed. These are the number of characters that were
dropped from the String, and the average number of characters dropped per word within the
String.
The User is then asked if they would like to shorten another String accepting ‘Y’ or ‘y’ (for
yes) continue, and quitting on all other input.
The User will then have displayed for them a count of how many Strings they abbreviated.
This link shows an example of the output that a correctly written program would produce, the words in the
messages do not have to be exactly the same as this, but the calculations should be correct. For your
information, my program is about 125 lines long and contains about 9 final variables.
题目要求的运行结果:
Sample run of the program (user input is bold)
Please enter a Sentence
The Quick Brown Fox
Abbreviated String: Th Qck Brwn Fx
Sentence Stats
Number of Words: 4
Average number of letters dropped per word: 1.25
Do you want to try another? (y/n)
Y
Please enter a Sentence
I like bananas
Abbreviated String: I lk bns
Sentence Stats
Number of Words: 3
Average number of letters dropped per word: 2.0
Do you want to try another? (y/n)
y
Please enter a Sentence
Laughing should never be banned
Abbreviated String: Lghng shld nvr b bnd
Sentence Stats
Number of Words: 5
Average number of letters dropped per word: 2.2
Do you want to try another? (y/n)
n