You are actually checking the value of
word
to see if it is a palindrome.
eye
view
is not a palindrome. If you want to check those individual words then you have to put in some processing to separate the words out e.g split by
\n
and handle each result in that array in a loop.
If you change your code to
string word = value1;
then it correctly notes this is a palindrome.
Perhaps the most famous palindrome is "Madam, I'm Adam". Your code will not view this as a palindrome because:
1. You are not removing or handling punctuation marks such as
'
,
,
etc
2. You are not handling differences in case
M
should be "equal" to
m
for the purposes of finding a palindrome.
3. You are inserting
\n
into your test data.