1.) Take in a word from the User 2.) create a character stack that will store th
ID: 3531129 • Letter: 1
Question
1.) Take in a word from the User 2.) create a character stack that will store the word. Use a for loop to push each letter onto the stack. 3.) Write a method that takes in the stack and string a parameters. It should return a boolean if the word is palindrome. public static boolean isPalindrome(Stackin, String input_str) print and tell the user if the word is a palindrome or not----------------------- What I have so far------ import java.util.Scanner; public class Bowen9 { public static void main(String [] args) { Scanner input = new Scanner(System.in); System.out.println("Type in a word: "); String word = input.nextLine(); Stack letters = new Stack(); for(int i = 0; iExplanation / Answer
public char[] input = new char[]{'a','b','d','h','i','s','f','t'}; public String longestString = dict[0]; public Test() { System.out.println(longestString); ArrayList convert = new ArrayList(); for(String counter : dict) convert.add(counter); getInstance(convert, 0, input.length, 0, 0); System.out.println(" " + longestString); } private void getInstance(ArrayList searching, int pos, int length, int starter, int currentI) { int i = starter; do{ ArrayList matched = new ArrayList(); for(String counter : searching) { if(counter.length() > pos) { if(counter.charAt(pos) == input[i]){ matched.add(counter); } } } if(matched.size() > 0) { getInstance(matched, pos+1,length,(i+1)%length, i%length); } else if(currentI != i && matched.size() > 0) { getInstance(searching,pos,length,(i+1)%length, i%length); } if(matched.size() > 0 && longestString.length()Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.