Java Word Processor
Problem: Design and implement a class called WordProcessor. This class is
used to:
? hold a line of text that can be manipulated in various ways
? perform various manipulations and modify the text
? return a string with a list of all the palindromes in the text (a palindrome
reads the same forwards as backwards)
? return a Pig Latin version of the text (see description below)
? return several counts about the text
o number of words (a hyphenated word is one word),
o number of sentences (ends in a period),
o number of questions (ends in a question mark),
o number of exclamations (ends in an exclamation mark!),
Helpful information and requirements for your WordProcessor class - you must
name your methods exactly as shown here:
? You can break up a String into words or "tokens" by using java?s Scanner
class. When constructing your Scanner, you will pass a String as a
parameter (not System.in). The Scanner methods necessary to break it
up are hasNext() and next(). See the ScannerDemo.java posted on our
class webpage to see how this works.
? Legal punctuation for the text is periods, question marks, exclamation
marks, hyphens (within a word), and apostrophes. Words will have only a
single space between them.
? Your class should have 2 constructors: one that has no parameters and
a second one that takes a line of text as a parameter. Each constructor
should initialize all instance variables.
? Write a public method setText that takes a String parameter and changes
the current text to this new String. If no text existed before, this sets it. If
there was text, this method will overwrite it. It doesn't return anything.
? Write a public method toString that takes no parameters but returns the
current version of the text.
? Write public methods getNumberOfWords, getNumberOfSentences,
getNumberOfQuestions, getNumberOfExclamations that return the counts
of how often each of these things occur in the text.
? Write a public method replaceWord that takes two String parameters. The
first parameter is the word to replace, the second parameter is what
to replace it with in the text. All occurrences of the first word should be
changed to the second. This method does not return anything. You
may not use the String method replace, replaceAll, or
replaceFirst :-).
? Write a public method appendText that takes a String parameter and
appends (adds it to the end) it to the current text. If no text existed before,
this sets it. It doesn't return anything.
? Write a public method getPalindromes that takes no parameters, but
returns a String that has all the words in the text that are palindromes
concatenated together, each one separated by a space. A palindrome
reads the same forward as backwards ignoring case and internal
punctuation). For example: noon, Sara?s, radar are all palindromes.
? Write a public method getPigLatinVersion that takes no parameters, but
returns the Pig Latin translation of the text. This method does not modify
or change the original text. You may want to have one or more "private"
methods to help this method do its work. To convert a word to Pig Latin:
o if the word begins with a vowel (a, e, i, o, u), then just add ?ay? at the
end of the word.
o if the word begins with one or more consonants, move all initial
consonants (up to the first vowel) to the end of the word and add ?ay? at
the end.
o if the word is all consonants, then just add ?ay? at the end.
o leave any internal punctuation (apostrophes and hyphens) where it is
in the original string. For example Sara?s becomes Ara?ssay
o word separators such as commas, periods, etc. should not be included
in the middle of a Pig Latin version of a word but should occur after the
word as before.
o if the original first letter of a word is capitalized, the Pig Latinized
version of the word should also begin with a capital letter.
Hints:
? Start early! This assignment will take some involved problem solving
techniques.
? Work up your solution incrementally as we've discussed in class. For
example, initially make sure that each of your constructors work. Then add
other methods such as the number of words, sentences, etc.
? If you?re having trouble making it work with capitalization and punctuation,
use a simplified input with all lower case letters and no punctuation, then
work up from there.
? You should always have a compiling, working class at each stage of
development.
? Ask questions!
View Answers
Related Tutorials/Questions & Answers:
Java Word ProcessorJava Word Processor Problem: Design and implement a class called... of words (a hyphenated
word is one
word),
o number of sentences (ends...:
? You can break up a String into words or "tokens" by using
java?s Scanner
Advertisements
Word replacment - Java BeginnersWord replacment
Java code for the
Word Replacement.Thnaks in Advance! Hipublic class WordReplaced{ public static void main(String[] args... information,http://www.roseindia.net/
java PDF to Word Conversion - Java BeginnersPDF to
Word Conversion Hello,
Can we convert a PDF document to Microsoft
word document thru
Java.
If its not possible in
Java, is it possible in any other language
word program - Java Beginnersword program HELLO MAM AND SIR I ASK YOUR HELP HOPE YOU GONNA HELP ME THANK YOU!!Design a program to search a
word for letters that the user... within the
word a letter that the user entered,change the value of the array
java number to word - Java Beginnersjava number to word Can somebody please fix this to come out with the
word, not the number 23?
import java.util.Scanner;
public class...
{
//-----------------------------------------------------------------
// Pulls integers from a string to form a
word java word counting - Java Beginnersjava word counting Hi I want a code in
java that replaces a
word with another when its occurred independently and ignores the case of the text... but this will change all the occurrence even if its part of another
word the run
word and character counting - Java Beginnersword and character counting here is the
java code i made but i have to add something where it will read the inFile and display the number of words... = null;
String
word;
int numLines = 0;
int numWords = 0
export to word document - Java Beginnersexport to
word document hi sir,when i am click on a button under the jtable,for example (print button),then i want to print that jtable in
word document,automatically,plz provide program sir Hi Friend,
Try
create MS Word in Java - Java Beginners which creates MS
Word in
Java...create MS
Word in Java Hi,
Could any one please post the code which creates the
word document having different paragraphs and two tables.
i have
Java word extraction program. - Java BeginnersJava word extraction program. Need to code a public class named...- character
word. The starting position should be based on the leftmost character... position and display the
word on the console screen.
Thanks
Creating MS Word document in java - StrutsCreating MS
Word document in java I have one template in MS
Word which has some content. Now i want to read this doc file and wants to add some... you plz tell me how to do in
java Final Key Word in Java
.style1 {
text-align: center;
}
Final key
word in
java
In
java final is a key
word used in several different contexts. It is used
before... is a final variable introduced in
java 1.1, its declaration
lacks
Auto complete of word search using ajax with javaAuto complete of
word search using ajax with java I want to display the list of words when I type the first letter of the
word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Auto complete of word search using ajax with javaAuto complete of
word search using ajax with java I want to display the list of words when I type the first letter of the
word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Find Longest Word from the string using JavaFind Longest
Word from the string using
Java
Here we are going to find the longest
word from the string. For this, we have
specified the string which... and allow the longest
word to display.
Here is the code
Execute the java program using one processorExecute the
java program using one processor
Write a program to print the number series 1, 2,3, 4ΓΆβ?¬Β¦.100 using
java programming language in dual core computer
a) Execute the program using one
processor
b) Execute
open word documentopen
word document how to open a
word document ??
Please go through the following link:
Java Read
word document file
The above link will provide an example that will read the document file using POI library in
java open word documentopen
word document how to open a
word document ??
Please go through the following link:
Java Read
word document file
The above link will provide an example that will read the document file using POI library in
java open word documentopen
word document how to open a
word document ??
Please go through the following link:
Java Read
word document file
The above link will provide an example that will read the document file using POI library in
java Search word from text file using JavaHow to Search
word from text file using
Java
In this section, we are going to search a
word from the text file. For this, we have created a swing button. On clicking, it will open another window that will ask the user to enter name. When
MicroSoft wordMicroSoft word sir i want to develop an swing application like the microsoft
word Document.can you help me pls
Java Word Occurrence ExampleJava Word Occurrence Example
In this example we will discuss about the how... can count the occurrences of each
word
in a file. In this example we will use... name from command line which returns the
number of occurrences of each
word