your task is to create a program that will check to see if a string that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
your task is to create a program that will check to see if a string that the user enters is a palindrome. Using the PalindromeChecker starter code in the right panel, you are to write 3 methods: 1. isPalindrome() - write a method that uses the charAt() method 2. isPalindrome2() - write a method that uses the substring() method and the equals() method for comparison. Use the same local variables and for loop from the isPalindrome() method by copying and pasting. 3. isPalindrome3() - write a method that creates a new string concatenating each letter in reverse order and then making a comparison to the original string. Local variables and a loop are provided. The autograder is looking for output in the following format in this method: "The string " + str + " is a palindrome." or "The string " + str + " isn't a palindrome." The program will ask the user to enter a word and then should display whether or not the word is a palindrome for all 3 methods. There are comments in the code to give you direction. ✓ Which topic did your group research and what were your findings on the topic? Submit Answer! Research Palindrome Group Work In order to prepare for your next coding assignment, you will need to research what a palindrome is. For this activity you will work in groups and research one of the following topics (assigned by your teacher): • What is a palindrome? (list examples and define the term) • What Java programs exist that are palindrome checkers? (prepare samples to share with the class) • What String class methods are used in palindrome checker programs? о charAt() - evaluates primitive data type о substring() - evaluates reference data type • What else can be done with a palindrome program to make it interesting or unique? • What is the logic common to each program in determining a palindrome? • How can a control structure be used to create an effective palindrome program? Here is the link to the Java API on the String class if needed Be prepared to report your findings to the class. PalindromeChec... 45 //your code goes here return true; public static void isPalindrome3 (String str) //reverses the String 46 47 } 48 49 50 } 51 52 53 { 54 55 56 57 58 59 String reverse = ""; int length = str.length(); for (int i = length 1; i >= 0; i--) 60 { 2 2 2 2 3 3 2 70 63 61 62 64 65 } 66 } 67 //your code goes here //since this is a void method you will not return but print a message 68 69 72 } //students, consider improvements and add ons..... //how could these methods be improved using Java's ignorecase() method? //can you remove the spaces in the phrase? PalindromeChec... 1 1234567890-23122222222222222222 { import java.util.Scanner; public class PalindromeChecker { } public static void main(String[] args) /* The Scanner class is used for reading in data to your program. */ Scanner keyboard = new Scanner(System.in); System.out.println("Please enter a word: "); String word = keyboard.nextLine(); // you will write isPalindrome (), isPalindrome2() and isPalindrome3 () System.out.println(word + " is a palindrome: " + isPalindrome (word)); //calls a boolean method System.out.println(word + " is a palindrome: " + isPalindrome2 (word)); //calls a boolean method 1sPalindrome3 (word); //calls a void method public static boolean ispalindrome (String str) //uses charAt method which returns a primitive data type and evals input { = int i, j; int len str.length(); j = len - - 1; for (i = 0; i <= (len - 1)/2; i++) //your code goes here If you and your partner finish early implement additional functionality in your Palindrome program as stated in comments in the starter code. Some ideas are: • make your palindrome checker case-sensitive • removing characters that are not letters and then check for a palindrome When you are ready to test your program, click the Compile and Run button to run the program. The output will display in the terminal panel. COMPILE AND RUN ✓ Palindrome Checker Auto-grader ☑ When you are ready to submit your program to the auto-grader, click the button below. Check It! your task is to create a program that will check to see if a string that the user enters is a palindrome. Using the PalindromeChecker starter code in the right panel, you are to write 3 methods: 1. isPalindrome() - write a method that uses the charAt() method 2. isPalindrome2() - write a method that uses the substring() method and the equals() method for comparison. Use the same local variables and for loop from the isPalindrome() method by copying and pasting. 3. isPalindrome3() - write a method that creates a new string concatenating each letter in reverse order and then making a comparison to the original string. Local variables and a loop are provided. The autograder is looking for output in the following format in this method: "The string " + str + " is a palindrome." or "The string " + str + " isn't a palindrome." The program will ask the user to enter a word and then should display whether or not the word is a palindrome for all 3 methods. There are comments in the code to give you direction. ✓ Which topic did your group research and what were your findings on the topic? Submit Answer! Research Palindrome Group Work In order to prepare for your next coding assignment, you will need to research what a palindrome is. For this activity you will work in groups and research one of the following topics (assigned by your teacher): • What is a palindrome? (list examples and define the term) • What Java programs exist that are palindrome checkers? (prepare samples to share with the class) • What String class methods are used in palindrome checker programs? о charAt() - evaluates primitive data type о substring() - evaluates reference data type • What else can be done with a palindrome program to make it interesting or unique? • What is the logic common to each program in determining a palindrome? • How can a control structure be used to create an effective palindrome program? Here is the link to the Java API on the String class if needed Be prepared to report your findings to the class. PalindromeChec... 45 //your code goes here return true; public static void isPalindrome3 (String str) //reverses the String 46 47 } 48 49 50 } 51 52 53 { 54 55 56 57 58 59 String reverse = ""; int length = str.length(); for (int i = length 1; i >= 0; i--) 60 { 2 2 2 2 3 3 2 70 63 61 62 64 65 } 66 } 67 //your code goes here //since this is a void method you will not return but print a message 68 69 72 } //students, consider improvements and add ons..... //how could these methods be improved using Java's ignorecase() method? //can you remove the spaces in the phrase? PalindromeChec... 1 1234567890-23122222222222222222 { import java.util.Scanner; public class PalindromeChecker { } public static void main(String[] args) /* The Scanner class is used for reading in data to your program. */ Scanner keyboard = new Scanner(System.in); System.out.println("Please enter a word: "); String word = keyboard.nextLine(); // you will write isPalindrome (), isPalindrome2() and isPalindrome3 () System.out.println(word + " is a palindrome: " + isPalindrome (word)); //calls a boolean method System.out.println(word + " is a palindrome: " + isPalindrome2 (word)); //calls a boolean method 1sPalindrome3 (word); //calls a void method public static boolean ispalindrome (String str) //uses charAt method which returns a primitive data type and evals input { = int i, j; int len str.length(); j = len - - 1; for (i = 0; i <= (len - 1)/2; i++) //your code goes here If you and your partner finish early implement additional functionality in your Palindrome program as stated in comments in the starter code. Some ideas are: • make your palindrome checker case-sensitive • removing characters that are not letters and then check for a palindrome When you are ready to test your program, click the Compile and Run button to run the program. The output will display in the terminal panel. COMPILE AND RUN ✓ Palindrome Checker Auto-grader ☑ When you are ready to submit your program to the auto-grader, click the button below. Check It!
Expert Answer:
Answer rating: 100% (QA)
Below is the modified starter code for the PalindromeChecker program with the implementation of the ... View the full answer
Related Book For
Management Science The Art of Modeling with Spreadsheets
ISBN: 978-1118582695
4th edition
Authors: Stephen G. Powell, Kenneth R. Baker
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
L = {w| L2 = {w| Two languages L1 and L2 are defined by symbols = {0, 1}, written as w contains 00 as a sub-string and the length of w is even number} w begins with 0 and ends with 1} (i) Write two...
-
What type of motor would you specify for a meat grinder if the motor is to be exposed?
-
Smith Distributors, Inc., supplies ice cream shops with various toppings for making sundaes. On November 17, 2018, a fire resulted in the loss of all of the toppings stored in one section of the...
-
The Sasakawa Sports Foundation conducted a national survey to assess the physical activity patterns of Japanese adults. The next table lists the frequency (average number of days in the past year)...
-
Are your rods or cones more important for reading a book?
-
Both iGAAP and U.S. GAAP require footnote disclosure of operating lease payments. Are there any differences in the information provided to statement readers in these disclosures? Explain.
-
Tommy started a business and paid $15,000 into the business bank account. Tommy also obtained a bank loan of $5,000 to help finance the business. How should be two transactions be classified in the...
-
Assuming Jay and JoAnn have this same business that they run as a partnership, prepare their joint Federal income tax return for 2022. Attached is the copy of the partnership K-1 for each of them....
-
Choose an organization whose operations and supply chain are of interest, preferably, an organization you are presently working for or an organization you have worked for in the past. Full details of...
-
Double A Ltd. is an importer of Craft from Switzerland. The company has contracted to purchase 3,000 items at a unit price of 18 Swiss Francs. Three months credit is allowed before payment is due....
-
A Barbados importer has a Euro 62,500 payment to make to a German exporter in 60 days. The importer is thinking of buying a call option to have the Euro delivered to it at a strike price of BBD 1.28...
-
Sales and Services Tax (SST) was reintroduced back in Malaysia on September 2018 in replace of the Goods and Service Tax (GST). Discuss how Sales and Service Tax (SST) brings the following social and...
-
It is desired to create an analog level indicator using the circuit. If the analog input is greater than 100 then display shows "H" character, otherwise display shows "L" character. Write a program...
-
Task: in a few sentences, explain your thoughts on these ads: 1) https://www.youtube.com/watch?v=IJNR2EpS0jw 2) https://www.youtube.com/watch?v=c_0bhT98g9Y (humour ad) 3)...
-
1+2z+z2 Detemine the signal x[n]if its Z-transform X[z] is given by X[z]: %3D 4+4z+z2
-
CdF2 (s) Cd+ (aq) + 2 F- (aq) 1. A saturated solution of CdF2 is prepared. The equilibrium in the solution is represented above. In the solution [Cd+] eq = 0.0585 M and [F-] eq = 0.117 M. a....
-
The database Bank Marketing.xlsx** contains information on the results of a direct marketing campaign by a Portuguese bank. The purpose of the campaign was to enroll customers in a bank term deposit...
-
a. What percentage is predicted for 1999, assuming there are no changes in trends and policies? b. How does the percentage change as a function of BMW's market share in 1999? (Consider a range from 5...
-
During the next 8 months, Metropolis Power Company forecasts the demands shown in the table below (measured in thousands of kwh): Power will be supplied from the four generating facilities, GF1- GF4....
-
How would payments for taxes be classified? (a) Operating outflow. (b) Operating inflow. (c) Investing outflow. (d) Financing outflow
-
How would the repayment of debt principal be classified? (a) Operating outflow. (b) Operating inflow. (c) Investing outflow. (d) Financing outflow
-
What type of accounts are accounts receivable and inventory? (a) Cash accounts. (b) Operating accounts. (c) Financing accounts. (d) Investing accounts.
Study smarter with the SolutionInn App