Question
Purpose: To use software development principles of abstraction in problem solving and structured problem solving techniques to create an application that uses various control structures
Purpose: To use software development principles of abstraction in problem solving and structured problem solving techniques to create an application that uses various control structures the String.split method to tokenizes a sentence into induvial words.
Details:
Create a class called Sentence that contains the main method. The class should ask the user to enter a sentence, tokenize the sentence into individual words, and finally, display the words in reverse order, one word per line.
The sample code:
mport java.util.Scanner;
public class Sentence { public static void main(String [] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a sentence: "); String sentence = input.nextLine(); // tokenize sentence into individual tokens String[] tokens = sentence.split(" "); System.out.printf("The tokens are:%n", tokens.length); // display each token from end to beginning for (String token : tokens){ System.out.println(token); } } }
I don't know how to reverse each token. Please help me and give me explainations.
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started