Results 1 to 3 of 3
  1. #1
    snobbysteven is offline Member
    Join Date
    Oct 2012
    Posts
    17
    Rep Power
    0

    Angry Palindrome using Arrays

    for this assignment I have to have the user enter a word, and then determine if its a palindrome or not. when the user is done they enter a period. It must include a loop to allow the person to enter more strings. the program also requires that I have "public static boolean isPalindrome(char[] a, int used)". Im not very far yet and my brains shot from working on other java all day. So im kinda suck on where I should go next, and am I starting to make it too complex?

    Java Code:
    //CS123Ass9BID1832
    //
    
    import java.util.Scanner;
    
    public class Palindrome
    {
    
      char[] text = new char[80]; 
      
      public void getInput()
      {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Please enter your word one character at a time, place a period when done");
        text = keyboard.nextChar();
      }
      
      public void check()
      {
        int length = text.length();
        for( int index = length - 1; index >= 0; index--)
        {
          reverse = reverse + text.charAt(index);
          
        }
        
        
        public static boolean isPalindrome(char[] a, int used)
        {
          boolean wordsMatch = true;
          for(int index = 1; index <

  2. #2
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    393
    Rep Power
    5

    Default Re: Palindrome using Arrays

    Hi snobbysteven,

    Have a look at using the reverse method of the StringBuilder class. From here you can compare the String value reverse with the original to determine of the input is a palindrome.
    After this, wrap the code in a loop which checks if the user input is a period or not.

    Regards.

  3. #3
    snobbysteven is offline Member
    Join Date
    Oct 2012
    Posts
    17
    Rep Power
    0

Similar Threads

  1. palindrome
    By rochellelising in forum New To Java
    Replies: 1
    Last Post: 08-24-2011, 01:03 PM
  2. Palindrome
    By leepikamukharji in forum New To Java
    Replies: 2
    Last Post: 04-29-2011, 03:20 PM
  3. Palindrome program
    By trinity in forum New To Java
    Replies: 4
    Last Post: 04-16-2011, 03:22 AM
  4. Palindrome
    By pinkdreammsss in forum Java Applets
    Replies: 8
    Last Post: 05-04-2010, 03:59 PM
  5. HELP...Palindrome
    By d7o0om in forum New To Java
    Replies: 12
    Last Post: 11-13-2009, 03:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •