Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Double Palindrome problem: A palindrome is a string that reads the same forward

ID: 3738165 • Letter: D

Question

Double Palindrome problem: A palindrome is a string that reads the same forward and backward. The classic examples are “mom”, “level”, “madam”, “rotator”, etc. A double palindrome is a string that has two palindromes back to back. These are somewhat artificial and may not exist in any language. For example, strings like “mommom”, “madammadam” are double palindromes. Your task is to write a Java program, with a Stack data structure, to detect if a string is a double palindrome or not. You can either assume that the string is read in from the keyboard or hard-coded within the main () of your program. No credit for a solution that does not use Stack.

Explanation / Answer

import java.util.Scanner; import java.util.Stack; public class PalindromeStack { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str = "", rev = ""; System.out.print("Enter the string : "); str = scan.next(); Stack s = new Stack(); for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote