Difference between revisions of "Week 5"
From CompSciWiki
Line 3: | Line 3: | ||
|ProblemName=Palindromes | |ProblemName=Palindromes | ||
− | |Problem= | + | |Problem=<pre> |
− | <pre>Complete the program Palindrom below that checks if a word is palindrome. | + | Complete the program Palindrom below that checks if a word is palindrome. |
If the word is palindrome, print out "It's a palindrome." using System.out.println(). | If the word is palindrome, print out "It's a palindrome." using System.out.println(). | ||
Otherwise, print out reversed order of the word. | Otherwise, print out reversed order of the word. |
Revision as of 00:12, 2 April 2010
Back to the Program-A-Day homepage
ProblemComplete the program Palindrom below that checks if a word is palindrome. If the word is palindrome, print out "It's a palindrome." using System.out.println(). Otherwise, print out reversed order of the word. You will need to IGNORE the blanks in the string. Two strings are provided and find out whether they are palindromes or not. For example, "deed" and "civic" are palindromes. "tomato" and "mama" are not palindromes. public class asd { public static void main(String[] args) { String testWord1 = "Are we not drawn onward, we few, drawn onward to new era" String testWord2 = "Murder for a jar of red rum" // Your code goes here } } |
...by students
An image or By Students section | |
---|---|---|
SolutionThe solution... | ||
Code |