Question
code in java palindrome: a word, phrase, or sequence that reads the same backward as forward, e.g., madam Objective: Prompt the user for a word
code in java
palindrome: a word, phrase, or sequence that reads the same backward as forward, e.g., madam
Objective: Prompt the user for a word and then check if that word is a palindrome using a Stack data structure.
Requirements:
1) Only a single main class is required
2) The main class must contain a static method called "getInputWord" that prompts a user to input a word from the keyboard and returns that word as a String. This method must use "JOptionPane.showInputDialog" to get the input from the user (you can find info about JOptionPane in JavaDocs)
3) The main class must contain a static method called "palindromeCheck" that takes a String as an input argument and returns a boolean indicating whether or not that String is a palindrome. This method must utilize a Stack data structure to determine whether the word is a palindrome. Hint: Use the charAt() method of the String class to access each character of the word
Flow of the Program:
1) Read in a word from the user by calling your "getInputWord" method
2) Check if the word is a palindrome using your "palindromeCheck" method
3) Output the result to the screen using "JOptionPane.showMessageDialog" (you can find info about JOptionPane in JavaDocs)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started