Ask Experts Questions for FREE Help !
    wogboy95's Avatar
    wogboy95 Posts: 1, Reputation: 1
    New Member

    Sep 6, 2012, 07:29 PM
    Ask java questions live free
    I am having trouble with this question "Design and write an algorithm that will read a single word from the keyboard and prints to the screen whether this word is a palindrome or not. A palindrome is a word; (or sentence, but for this question we are only dealing with a single word); that is spelt the same way forwards as backwards. The program should then ask for another word and end if the word typed in is ‘STOP’.

    Please note that this will need to be done without arrays, as it is your ability to manipulate and compare characters that is being tested."

    All my attempts have been wrong

    Can you please help?
    jsblume's Avatar
    jsblume Posts: 13, Reputation: 2
    New Member

    Sep 28, 2012, 10:19 AM
    Reading a single word? First, I presume you are using the method. I haven't used it in a while, but usually this finishes the input capture when the enter key is pressed. Otherwise, you would have to test each character pressed until you got one that is not in the alphabet.

    Are you using a recursive process or not?

    For a non-recusive process without treating the word as an array (which it is anyway), you would use a for loop. My syntax may be buggy because I'm writing this here and not in a compiler.

    boolean isPalindrome = true;
    for (int I=0; I<word.length/2; I++) {
    if (word.substring(I,I) != word.substring(word.length-i-1) {
    isPalindrome = false;

Not your question? Ask your question View similar questions


Question Tools Search this Question
Search this Question:

Advanced Search

Check out some similar questions!

Java coding question [ 4 Answers ]

Suppose I have a text field in java (like in gmail home page you have username field ) So I want to fill that field automatically by taking record from the database so is there any mechanism in java to handle this problem??

Forum to ask questions about java [ 0 Answers ]

Hi all, I need to read following xml using java.. could you please help me in this? <LINE>002:OR,004:0001,002:01,002:01,007:SCEM_02,000:,007:590,000,002:KG,002:PC;/</LINE>

Ask questions regarding java [ 0 Answers ]

) If any situation system is goes in deadlock condition,how you can recover from that situation programmitically. b) How you can decide when to use static class or interface. What is difference between the two. Which one is better to use in which situation.

Totally free live major league baseball games live online [ 0 Answers ]

I'm looking for totally free, no hidden costs, no gimmicks, no free trial only, no virus or malware, proven reliable online feeds for live major league baseball games. I just want to go to the site, click on the game I want to watch and simply watch the game. This is so much harder to find than it...

Java questions - I need the answers [ 3 Answers ]

Declare each of the following: (a) a field of data type boolean and name isFound; (b) a local variable of data type String and name carModel; (c) a field of data type double and name weight; (d) a field of data type Employee and name secretary. 2. Write a declaration for an array variable...

View more questions Search