Java Word Processor

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 Processor
Java 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
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Advertisements
Word replacment - Java Beginners
Word 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
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
PDF to Word Conversion - Java Beginners
PDF 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 Beginners
word 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 Beginners
java 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 code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
java word counting - Java Beginners
java 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 Beginners
word 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
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.  **A program in JAVA which accepts a sentence & displays the longest word in the sentence along
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
export to word document - Java Beginners
export 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
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Java word extraction program. - Java Beginners
Java 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
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Creating MS Word document in java - Struts
Creating 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
How to Open Text or Word File on JButton Click in Java - Java Beginners
How to Open Text or Word File on JButton Click in Java  How to Open Text or Word File on JButton Click in Java
how to translate english word to marathi using java
how to translate english word to marathi using java  I want to translat english word to marathi,how i can develop a code for that ,please sajest me
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using 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 java
Auto 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 java
Auto 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
Using poi hwpf,how to create table in word document. - Java Beginners
Using poi hwpf,how to create table in word document.  Can you please tell me how to create a table in the word document in java using Apache poi hwpf.its very urgent.Please send some sample code.Thanks in advance
Edit word document Headers and Footers using POI Library in java?
Edit word document Headers and Footers using POI Library in java?  Hi All, I need code to modify the Header and Footer contents of a ms-word template using POI or JACOB libraries. Could any one help me? Thanks Advance
Find Longest Word from the string using Java
Find 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
Java - search/find a word in a text file - Java Beginners
Java - search/find a word in a text file  Hello, I would like... to search them for a word. The word will be PASS or it can be FAIL. If PASS I...); System.out.print("Enter word to find: "); String word=input.next
Compare two word file
Compare two word file  How to compare two word file using Java
Execute the java program using one processor
Execute 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
viewing the ms word in print layout from jsp - Java Beginners
viewing the ms word in print layout from jsp  Hi all, I am trying to export ms word from jsp in print layout format.I used the code for converting into ms word but it is opening in web layout. My requirement
open word document
open 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 document
open 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 document
open 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 Java
How 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 word
MicroSoft word  sir i want to develop an swing application like the microsoft word Document.can you help me pls
Java Word Occurrence Example
Java 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

Ads