Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Word Processor
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


jamie valley
Java Word Processor
0 Answer(s)      a year and 5 months ago
Posted in : Java Beginners


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!


Advertisement
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
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
Advertisements
How to Communicate with the operating system embedded on processor running on hardware machine in java
How to Communicate with the operating system embedded on processor running... system embedded on processor running on hardware machine .Now as per my need i have to communicate with the opearating system using java tools. Will you plz
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 notepad file into Ms word file in 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
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
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
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 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
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 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
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
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
XML XPointer processor
XML XPointer processor  Hi..... Please anyone tell me about How do I configure an XPointer processor? Thanks
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
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
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
;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
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
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 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
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
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 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
Advertisements
 

 

 

DMCA.com