Question: In this chapters Programming Activity 1 folder, you will find the source files needed to complete this activity. Copy all of the files to a
In this chapters Programming Activity 1 folder, you will find the source files needed to complete this activity. Copy all of the files to a folder on your computer. Note that all files should be in the same folder.
Open the PalindromeDrawing.java source file. Searching for five asterisks (*****) in the source code will position you to the location where you will add your code. In this task, you will fill in the code inside the recursivePalindrome method to determine if a String representing a word or a sentence is a palindrome. The method returns true if the String is a palindrome, false if the String is not a palindrome. Example 13.7 shows the section of the PalindromeDrawing source code where you will add your code.
EXAMPLE 13.7 Location of Student Code in PalindromeDrawing public boolean recursivePalindrome( String pal ) { // ***** Student writes the body of this method *****
// Using recursion, determine if a String representing // a word or a sentence is a palindrome // If it is, return true, otherwise return false
// We call the animate method inside the body of this method // The call to animate is already coded below
animate( pal );
// // Student code starts here //
return true; // replace this dummy return statement
// // End of student code - PA 1 // }
Task Instructions Inside the method recursivePalindrome of class PalindromeDrawing write the code to solve the palindrome problem:
The recursivePalindrome method header has already been coded for you. Write the code to check if the parameter of the method, pal, is a palindrome. Return true if it is, false if it is not. Your method should be recursive; that is, it should call itself. We have provided a dummy return statement so that the code will compile. You should replace the dummy statement with your appropriate return statement.
Be sure your code ignores case differences; that is, Otto and Racecar are indeed palindromes.
The call to the animate method has already been written for you. It should be the first statement in the body of the method and is simply:
animate( pal );
In java/netbeans please
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
