Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ive had some trouble making this program work out. Write an original Java program to parse the words from a long String. The Java library

Ive had some trouble making this program work out.

Write an original Java program to parse the words from a long String. The Java library offers similar functonality within its tokenizer classes, but you should not use those for this assignment. Hand in one Java class called SentenceParser. Yor class should be able to break the given sentnece into words, where word is defined as the characters between any spaces, commas, or periods. The class should have a constructor that takes a sentence as a parameter. The class should define several public value methods. The class should have one method called "public static void main ()" that demonstrates what your class can do with the specific hard-coded sentence shown below. The demonstration should write this text to the console:

The quick brown fox jumped over the lazy dog.

This is the code we've been provided to help us. My professor doesnt want us to use any sort of Java shortcuts in this program either. Any help is appriciated.

image text in transcribed

Compile Undo Cut Copy PasteFind.. Close SourcC public class SentenceParser f String sentence; String[ lwords; Ub1 3cn Sentenceparser (string ) s; parse( sentence) ; words System. out.printIn( "Number of words is "+words. length public static void main() Sentence Pa r se r sp = new SentenceParser ("Pea ses and ca public Stringl ] parse(String s)f public int unique (Stringl Jw) return w.length public int countUnique () int u e: int w; int z; for (w-e: wswords .1ength; w+t)f u+t: for(z-w:z-0:z-)1 if(words[wl.equals (wordslz]))r break; return u Ecre

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions