2. Declare and implement a class named MyQuote. This class will have a string data member quote consisting of English words with special characters and the following methods: a. A constructor: initialize quote with the null string ("" is the null string). b. setMyQuote (): get a string as input parameter and assign it to quote. c. split(): pull out each word in quote, save it in string variable w, and print w using System.out.println() statement. For example, if quote="Never give up. Today is hard, tomorrow will be worse, but the day after tomorrow will be sunshine!", this method will print: never give up Today is hard tomorrow will be worse but the day after tomorrow will be sunshine Note that special characters and blanks are not part of words and should be excluded when each word is picked. It is also possible that some special character like blank may appear on quote multiple times in a row. You must use a for loop and the string methods length(), toLowerCase(), and charAt() are the only built-in methods allowed in this assignment. You will also have a main class with the main method in it. The main method will create an object of MyQuote class and call the setMyQuote() and split() methods.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
Absolutely lost on this assignment. Any help would be greatly appreciated.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images