Question: Write a Java program (called Lab6Exercise2) to read a sentence (as a single string) from the user, the program prints out the entered sentence. then
Write a Java program (called Lab6Exercise2) to read a sentence (as a single string) from the user, the program prints out the entered sentence. then utilize loops to print out the sentence one word per line using the space (blank) character as the delimiter. (Your program should be able to handle instances of multiple spaces betweens words and the possibility that there are spaces at the beginning and end of the sentence.) Use prop labels and line up the outputs as shown in the examples below. Design your program to allow the user to re-run the program with a different input. (NOTE: The only methods from the Java standard library class String which may be used in this exercise are .length(), .charAt(), and .trim().)
Exercise 2: Write a Java program (called Lab6Exercise2)to read a sentence (as a single string) from the user, the program then prints out the entered sentence. Then utilize loops to print out the sentence one word per line using the space (blank) character as the delimiter. (Your program should be able to handle instances of multiple spaces between words and the possibility that there are spaces at the beginning and end of the sentence.) Use proper labels and line up the outputs as shown in the examples below. Design your program to allow the user to re-run the program with a different input. (NOTE: The only methods from the Java standard library class String which may be used in this exercise are length(), charAt(), and trim0).) Entered String: This is a test input, and can be a longer string too. Word Word Word Word Word Word Word Word Word Word Word Word #1: #2: #3: #4: #5: #6: #7: #8: #9: #10: #11: #12: This is test input, and can be longer string too
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
