Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /**
  2. *
  3. * @author Mike
  4. */
  5. import java.util.Scanner;
  6.  
  7. /**
  8. A program reads in a string,
  9. prints out the last character of the string,
  10. followed by the first character, and then
  11. followed by the three middle character of the string.
  12. All input strings should be of odd length.
  13. */
  14. public class StringGames
  15. {
  16. public static void main (String[] args)
  17. {
  18. // Display prompt for input string
  19. System.out.println("Please enter a string: ");
  20.  
  21. // Read string
  22. Scanner in = new Scanner(System.in);
  23. String input = in.next();
  24.  
  25. // Put together new string and print
  26.  
  27. // Your work here
  28.  
  29.  
  30. System.out.print(input.substring(input.length() - 1)); //last
  31.  
  32. System.out.print(input.charAt(0)); //first
  33.  
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement