Question
Sentence word reverser Design and implement a class (that includes a main method) that reads a sentence from the user and prints the sentence out
Sentence word reverser Design and implement a class (that includes a main method) that reads a sentence from the user and prints the sentence out with the words in the SAME order, but with the characters of each word backwards. Use ArrayStack to reverse the characters of each word in the sentence. Hint! Using two Scanners for this will make getting and splitting the string easier. Use one to get the initial sentence from the input stream (using .nextLine()). Then use another that doesnt scan the input stream, but rather scans the string (using .next()) to get each word. The constructor to Scanner can be passed System.in for the input stream or a string instead. See the following session: Enter a sentence: Hello nice to meet you Reversing each word: olleH ecin ot teem uoy
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PLEASE USE THIS ALREADY GIVEN CLASSES / INTERFACE
public class EmptyCollectionException extends Exception { private static final long serialVersionUID = 358083002087971606L;
public EmptyCollectionException() { super(); } public EmptyCollectionException(String msg) { super(msg); } }
import java.util.Arrays;
public class ArrayStack
public interface StackADT
public class SentenceWordReverser {
public static void main(String[] args) { // TODO Auto-generated method stub
}
}
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