Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Mike
- */
- import java.util.Scanner;
- /**
- A program reads in a string,
- prints out the last character of the string,
- followed by the first character, and then
- followed by the three middle character of the string.
- All input strings should be of odd length.
- */
- public class StringGames
- {
- public static void main (String[] args)
- {
- // Display prompt for input string
- System.out.println("Please enter a string: ");
- // Read string
- Scanner in = new Scanner(System.in);
- String input = in.next();
- // Put together new string and print
- // Your work here
- System.out.print(input.substring(input.length() - 1)); //last
- System.out.print(input.charAt(0)); //first
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement