You are given a text file named sentences.txt, which contains a list of sentences separated by newline characters. Each sentence is composed of words separated by spaces. Your task is to read the sentences, reverse each sentence, and then output the reversed sentences.
Input Format
The first line contains the number of sentences.
Following lines containes the sentences.
Hint: Standard Input : Scanner Class
Constraints
The length of each sentence does not exceed 100 characters.
The number of sentences in the input file does not exceed 100.
Output Format
Output the sentences in reversed manner.
Hint: Use StringBuilder | StringBuffer for easy reversal of sentences.
Sample Input 0
17
Programming is not hard.
Not sure if it's true.
Yes, it's true.
dog lazy the over jumps fox brown quick The.
nine saves time in stitch A.
beholder the of eye the in is Beauty.
words than louder speak Actions.
chocolates of box a like is Life.
worm the catches bird early The.
well ends well that All's.
perfect makes Practice.
way a there's will, a there's Where.
never than late Better.
more There's.
kidding Just.
Sample Output 0
hard not is Programming.
true it's if sure Not.
true it's, Yes.
The quick brown fox jumps over the lazy dog.
A stitch in time saves nine.
Beauty is in the eye of the beholder.
Actions speak louder than words.
Life is like a box of chocolates.
The early bird catches the worm.
All's that well ends well.
Practice makes perfect.
Where there's a will, there's a way.
Better late than never.
There's more.
Just kidding.
1
import java.io.*;
2
import java.util.*;
3
4
public class Solution {
5
6
public static void main(String[] args) {
7
8
}
9
}
What I have tried:
I tried but in the sentence true it's, Yes.
there is a comma before the period