Wap to reverse each word in the sentence and print the reversed string
Answers
Answered by
2
Answer:
package newPack;
import java.util.*;
public class reverseString {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);//create Scanner object
String s = input.nextLine();//read the input from the user
String[]a=s.split(" ");//divide the string into string array
for(int i = 0; i < a.length; i++) {//read each element in the array
for(int j = a[i].length()-1; j >= 0; j--) {//reverse
System.out.print(a[i].charAt(j));
}
System.out.print(" ");
}
}
}
Explanation:
This is written in java, hope it helpful!
Similar questions
History,
4 months ago
Social Sciences,
4 months ago
Hindi,
4 months ago
Physics,
9 months ago
English,
9 months ago