Starting from:

$20

CS570: Programming Foundations Assignment #5 Solution

Program #1: Iterative (non-recursive) palindrome program. (50%)

A palindrome is a string of characters that reads the same forward or backward. For example, the following strings are palindromes:

radar
noon
able was I ere I saw elba
Note that some palindromes have an even number of characters, whereas others have an odd number of characters.

Write an iterative (non-recursive) program called PalidromeTester which tests whether a given string is a palindrome.

A sample interaction with PalindromeTester is shown below:

Enter a potential palindrome:

radar

That string IS a palindrome.

Test another palindrome (y/n)? y

Enter a potential palindrome:

abracadabra

That string is NOT a palindrome.

Test another palindrome (y/n)? y

Enter a potential palindrome:

able was I ere I saw elba

That string IS a palindrome.

Test another palindrome (y/n)? n

As a minimum your program should be able to correctly determine palindromes considering spaces, punctuation marks, and changes in uppercase and lower case. That is, your program will be considered correct if given the strings “Radar” and “race car” it outputs that they are NOT palindromes.

Program #2: Recursive palindrome program. (50%)

Re-implement the palindrome program using a recursive solution.

 

 

More products