In: Computer Science
Java Programing
Write a program called reverseProg.
This program will do the following
Sample output example:
Enter a string: Wilmington University
String Entered is: Wilmington University
Wilmington University spelled backward is: ytsirevinU notgnimliW
The 7th character in the string is: T
The 8th character in the string is: O
The 9th character in the string is: N
Length of the string is: 21
import java.util.Scanner; public class reverseProg { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a string: "); String s = in.nextLine(); String rev = ""; for (int i = 0; i < s.length(); i++) { rev = s.charAt(i) + rev; } System.out.println("String Entered is: " + s); System.out.println(s + " spelled backward is: " + rev); System.out.println("The 7th character in the string is: " + Character.toUpperCase(s.charAt(7))); System.out.println("The 8th character in the string is: " + Character.toUpperCase(s.charAt(8))); System.out.println("The 9th character in the string is: " + Character.toUpperCase(s.charAt(9))); System.out.println("Length of the string is: " + s.length()); } }