Difference between revisions of "Week 5"

From CompSciWiki
Jump to: navigation, search
Line 3: Line 3:
 
|ProblemName=Palindromes
 
|ProblemName=Palindromes
  
|Problem=<pre>
+
|Problem=
Complete the program Palindrom below that checks if a word is palindrome.
+
Complete the program Palindrom below that checks if a word is palindrome.<br/>
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().<br/>
Otherwise, print out reversed order of the word.
+
Otherwise, print out reversed order of the word.<br/>
You will need to IGNORE the blanks in the string.
+
You will need to IGNORE the blanks in the string.<br/>
Two strings are provided and find out whether they are palindromes or not.
+
Two strings are provided and find out whether they are palindromes or not.<br/>
 
+
<br/>
For example, "deed" and "civic" are palindromes.
+
For example, "deed" and "civic" are palindromes.<br/>
"tomato" and "mama" are not palindromes.
+
"tomato" and "mama" are not palindromes.<br/>
 
+
<pre>
 
public class asd  
 
public class asd  
 
{
 
{

Revision as of 00:13, 2 April 2010

Back to the Program-A-Day homepage

Problem

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().
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

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

The solution...

Code

Solution Code

Back to the Program-A-Day homepage