using System ; using System . Collections . Generic ; using System . Linq ; using System . Text ; namespace Assig3 { class Program { static string name ; static string sentence ; static bool output ; static private bool IsSentencePalindrome ( string phrase ) { int length ; phrase = phrase . Replace ( " " , "" ); phrase = phrase . Replace ( "." , "" ); phrase = phrase . Replace ( "," , "" ); phrase = phrase . Replace ( "'" , "" ); phrase = phrase . Replace ( "-" , "" ); phrase = phrase . Replace ( "_" , "" ); phrase = phrase . Replace ( "/" , "" ); phrase = phrase . Replace ( "*" , "" ); phrase = phrase . Replace ( ":" , "" ); phrase = phrase . Replace ( "&" , "" ); phrase = phrase . Replace ( "(" , "" ); phrase = phrase . Replace ( "%" , "" ); phrase = phrase . Replace ( "$" , "" ); phrase = phrase . Replace ( "#" , "" ); phrase = phrase . Replace ( ")" , "" ); phrase = phrase . Replace ( "1" , "" ); phrase = phrase . Replace ( "2" , "" ); phrase = phrase . Replace ( "3" , "" ); phrase = phrase . Replace ( "4" , "" ); phrase = phrase . Replace ( "5" , "" ); phrase = phrase . Replace ( "6" , "" ); phrase = phrase . Replace ( "7" , "" ); phrase = phrase . Replace ( "8" , "" ); phrase = phrase . Replace ( "9" , "" ); phrase = phrase . Replace ( "Q" , "q" ); phrase = phrase . Replace ( "W" , "w" ); phrase = phrase . Replace ( "E" , "e" ); phrase = phrase . Replace ( "R" , "r" ); phrase = phrase . Replace ( "T" , "t" ); phrase = phrase . Replace ( "Y" , "y" ); phrase = phrase . Replace ( "U" , "u" ); phrase = phrase . Replace ( "I" , "i" ); phrase = phrase . Replace ( "O" , "o" ); phrase = phrase . Replace ( "P" , "p" ); phrase = phrase . Replace ( "A" , "a" ); phrase = phrase . Replace ( "S" , "s" ); phrase = phrase . Replace ( "D" , "d" ); phrase = phrase . Replace ( "F" , "f" ); phrase = phrase . Replace ( "G" , "g" ); phrase = phrase . Replace ( "H" , "h" ); phrase = phrase . Replace ( "J" , "j" ); phrase = phrase . Replace ( "K" , "k" ); phrase = phrase . Replace ( "L" , "l" ); phrase = phrase . Replace ( "Z" , "z" ); phrase = phrase . Replace ( "X" , "x" ); phrase = phrase . Replace ( "C" , "c" ); phrase = phrase . Replace ( "V" , "v" ); phrase = phrase . Replace ( "B" , "b" ); phrase = phrase . Replace ( "N" , "n" ); phrase = phrase . Replace ( "M" , "m" ); phrase = phrase . Replace ( "?" , "" ); length = phrase . Length ; char [] reversedPhrase = phrase . ToCharArray (); Array . Reverse ( reversedPhrase ); //Reverses the phrase string reversedString = new string ( reversedPhrase ); bool result ; if ( string . Compare ( reversedString , phrase ) == 0 ) { result = true ; } else { result = false ; } return result ; } static void Main ( string [] args ) { ` Console . ForegroundColor = ConsoleColor . White ; Console . WriteLine ( "Hello, what's your name?" ); name = Convert . ToString ( Console . ReadLine ()); Console . Clear (); Console . WriteLine ( "Welcome to my test program," + name + ( "." ) + ( "

Press enter to continue" )); Console . ReadLine (); Console . Clear (); Console . WriteLine ( "This program will tell you if your sentence is a palindrome.

Press enter to try out the application." ); Console . ReadLine (); Console . Clear (); int i ; for ( i = 0 ; i < 1000 ; i ++ ) { Console . WriteLine ( "Please enter a sentence then press Enter." ); sentence = Convert . ToString ( Console . ReadLine ()); output = IsSentencePalindrome ( sentence ); if ( output == true ) { Console . WriteLine ( "Your phrase is a Palindrome, press enter to continue." ); Console . ReadLine (); Console . Clear (); } if ( output == false ) { Console . WriteLine ( "Your phrase is not a Palindrome, press enter to continue." ); Console . ReadLine (); Console . Clear (); } } } } }