Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write aprogram MyTokenTester.java that reads in a sentence and displaysthe sente

ID: 3618588 • Letter: W

Question

Write aprogram MyTokenTester.java that reads in a sentence and displaysthe sentence in reverse order. Use the split method to extract eachword from the sentence. If there is punctuation at the end of thesentence you must remove it and place it at the end of the reversesentence. The program should keep running until the user types“quit”.
For example:
I went toschool. school towent I. Write aprogram MyTokenTester.java that reads in a sentence and displaysthe sentence in reverse order. Use the split method to extract eachword from the sentence. If there is punctuation at the end of thesentence you must remove it and place it at the end of the reversesentence. The program should keep running until the user types“quit”.
For example:
I went toschool. school towent I.

Explanation / Answer

Dear... Here is the code... import java.io.*;
class MyTokenTester
{
public static void main(String arg[])
{  
  //String initialized
  String str="I went to school.";
  //split in to tokens
  String []tokens=str.split("[ .]");
  //loop repeats in printing
  for(int i=(tokens.length-1);i>=0;i--)
   System.out.print(" "+tokens[i]);
   System.out.print(str.charAt(str.length()-1));
        //exit program
  System.exit(0);
}//end main
}
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote