Created
May 12, 2015 16:07
-
-
Save MrBean83/eed68427ba38ae7dc9c2 to your computer and use it in GitHub Desktop.
Revisions
-
MrBean83 created this gist
May 12, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import javax.swing.JOptionPane; public class StringOddEven { public static void main(String args[]) { String input = JOptionPane.showInputDialog("Please enter a string."); int length = input.length(); if (length % 2 == 0) { System.out.println(input); } else { int i = length - 1; // Using a DO-WHILE loop for this program. do { System.out.print(input.charAt(i)); i--; } while (i >= 0); // end do-while } // end if } // end main } // end class