Guest User

Untitled

a guest
May 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * Code by: Faiz Ikhwan Bin Mohd Rafhan Syamil
  3. * 2016647102
  4. * CS2304B
  5. * Date: 14 May 2018
  6. * Due Date: 21 May 2018
  7. */
  8. import java.util.Stack;
  9. import java.util.Scanner;
  10.  
  11. public class CreateAPalindrome
  12. {
  13. public static void main(String[] args) {
  14. Stack<Character> stack1 = new Stack<Character>(); //create stack
  15. Scanner input = new Scanner(System.in);
  16. String res = "";
  17.  
  18. System.out.println("Please enter a word: ");
  19. String inp = input.next();
  20.  
  21. for (int i = 0; i < inp.length(); i++)
  22. stack1.push(inp.charAt(i));
  23.  
  24.  
  25. while (!stack1.empty())
  26. {
  27. Character b = stack1.pop();
  28. inp += b.charValue();
  29. }
  30.  
  31. System.out.println(inp);
  32. }
  33. }
Add Comment
Please, Sign In to add comment