Assignment 04 - PART 2 Palindromes (50 points) - Note Part 2 is a separate deliverable: In this part, you will use stacks to recognize palindromes. Palindromes are strings that read the same backward as forward (for example "madam"). Write a program to read a line in from the keyboard and print to the display, whether or not it is a palindrome. You will use three stacks to implement the program. For simplicity use only lower-case letters in your test strings. Use the following logic 1. Push original string onto Stack_1 and also Stack_2 2. Pop Stack_1 and push onto Stack_3 until Stack_1 is empty 3. At this point Stack_2 is the original string and Stack_3 is the reverse 4. Compare Stack_2 and Stack_3 using dot = 5. If Stack_2 is equal to Stack_3 the string is a palindrome Test your string by entering data from the keyboard and writing out to the screen whether the string is a palindrome.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

Please write this in java. Add comments and keep the code neat. No need to be extra and add extra things.

Assignment 04 - PART 2 Palindromes (50 points) - Note Part 2 is a separate deliverable:
In this part, you will use stacks to recognize palindromes. Palindromes are strings that read the same
backward as forward (for example "madam"). Write a program to read a line in from the keyboard and
print to the display, whether or not it is a palindrome. You will use three stacks to implement the
program. For simplicity use only lower-case letters in your test strings.
Use the following logic
1. Push original string onto Stack_1 and also Stack_2
2. Pop Stack_1 and push onto Stack_3 until Stack_1 is empty
3. At this point Stack_2 is the original string and Stack_3 is the reverse
4. Compare Stack_2 and Stack_3 using dot =
5. If Stack_2 is equal to Stack_3 the string is a palindrome
Test your string by entering data from the keyboard and writing out to the screen whether the string is
a palindrome.
Transcribed Image Text:Assignment 04 - PART 2 Palindromes (50 points) - Note Part 2 is a separate deliverable: In this part, you will use stacks to recognize palindromes. Palindromes are strings that read the same backward as forward (for example "madam"). Write a program to read a line in from the keyboard and print to the display, whether or not it is a palindrome. You will use three stacks to implement the program. For simplicity use only lower-case letters in your test strings. Use the following logic 1. Push original string onto Stack_1 and also Stack_2 2. Pop Stack_1 and push onto Stack_3 until Stack_1 is empty 3. At this point Stack_2 is the original string and Stack_3 is the reverse 4. Compare Stack_2 and Stack_3 using dot = 5. If Stack_2 is equal to Stack_3 the string is a palindrome Test your string by entering data from the keyboard and writing out to the screen whether the string is a palindrome.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning