Write a Java function that receives as parameter a word and returns true if the word received as input is a palindrome, and false otherwise. Palindrome is a word that when written backwards has the
same spelling of the word written in the normal position, such as RADAR, ASA, ARARA.
Paulo Correa, Desenvolvimento de Software, (55 19)8126-8418
My function return TRUE or FALSE, ex:
I have a word: RADAR. If i write as opposed the word, the result is RADAR, so my function return TRUE.
I have other word: CASA. If I write as opposed the word, the result is ASAC, so my function return FALSE.
Costi Ciudatu wrote:I was just thinking: why tease the poor guy with maieutics when he's looking for something to paste .
Because this appears to be a homework assignment and if we hand out solutions he won't learn anything. In the end Paulo needs to be able to write code for these problems himself or he will fail his class.
I am 100% serious when I say this is how I start EVERY program I ever write. The best way to code is to write as little as possible before compiling and testing. This is the minimum code you can write to start and see it do something.
Next I'd read the problem and try and break down everything. The first thing is says is "Write a Java function..." So, see if you can write a java function. it doesn't have to take any parameters, it doesn't have to return anything, it doesn't have to DO anything...just see if you can write one and get your code to compile and run.
Once you have THAT done, try the next part...have it take a 'word' (what kind of object would you use for that???) and do nothing else but print it out inside the function...
at each and every step, write a line or two, compile, and test the hell out of it. Only when you are sure the previous step is right should you move on to adding something new.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors