Read a single sentence and print the sentence in a reverse order. The sentence will be a maximum of one hundred (100) characters long and a minimum of ten (10) characters long.
Sample Output:
Enter a String: I am Legend!
Output: !dnegeL ma I
Screen Shot:


Code:
import javax.swing.JOptionPane;
public class reverse
{
public static void main(String[] args)
{
String input_message;
String input_new = "";
for(;;)
{
input_message = JOptionPane.showInputDialog("Enter a String (Max 100, Min 10)");
if(input_message.length() >= 10 && input_message.length() <= 100)
{
input_new = new StringBuffer(input_message).reverse().toString();
JOptionPane.showMessageDialog(null, input_new + " ", "Output:",JOptionPane.PLAIN_MESSAGE);
break;
}
else
{
continue;
}
}
}
}