Monty374

Name Backwards

Nov 28th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. package name.backwards;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6. *
  7. * @author Monty
  8. */
  9. public class NameBackwards {
  10.  
  11. /**
  12. * @param args the command line arguments
  13. */
  14. public static void main(String[] args) {
  15. String name;
  16. Scanner input = new Scanner(System.in);
  17. System.out.println("Enter name: ");
  18. name = input.nextLine();
  19.  
  20. char[] letters;
  21. letters = name.toCharArray();
  22.  
  23. System.out.println("\n");
  24. //int x = letters.length;
  25. int x = letters.length;
  26. while(x > 0){
  27. x -= 1;
  28. System.out.print(letters[x]+"\n");
  29.  
  30. }
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment