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

any help on this is greatly appreciated. ArrayStack: https://mega.nz/#!NvBC1CBb!

ID: 3756187 • Letter: A

Question

any help on this is greatly appreciated.

ArrayStack: https://mega.nz/#!NvBC1CBb!QFAlBcKpq0x1ZJ4wdaxhG38dA8sw6b98VwZrVox0glo

LinkedStack: https://mega.nz/#!ZjRW0IIQ!jChFyH3rylO44shTvbCYZCrPj1XakajESiqE6OjRWD4

Stack: https://mega.nz/#!p3YGkIiD!rVfDkDVWetY8ySMerAn8Ys_wIgrLrRRhPE7nW665GVE

Might need:

EmptyCollectionException: https://mega.nz/#!Z7JShQjI!l24eC2aMgUgAPIaU2gdAU15-FfFfh-d_mAa9quKZMMQ

StackDriver: https://mega.nz/#!cuRwwY5D!UXE0SxpV67eZRTYMjbSSGVtIow8s1avqwCwBwBFhQms

The Stack Class For this lab, you are to use the ArrayStack and LinkedStack classes that we wrote in class You will need to download the ArrayStack and LinkedStack classes and the Stack interface from the course website.Recall that the methods are » size () isEmpty () * peek () push (E element) » pop () » clear () Tasks 1. Write a class called ArrayPalindrome. ArrayPalindrome is to have the following in- stance variables and methods (a) Three ArrayStack instance variables (b) The constructor will take no parameters and will create the three stacks of type ArrayStack. (c) A public method called isPalindrome that takes a string parameter and returnsa boolean. The incoming string is the string you will check for palindromeness. You will need to examine the characters of the string one at a time and push them onto one of the stacks. The charAt (index) method will be helpful here. Bc sure to look at the String API for other useful methods 2. Write a main method for ArrayPalindrome that tests several strings, both palindromes and non-palindromes. Bc sure to test any boundary conditions the ArrayStack class and non-palindromes. Be sure to test any boundary conditions 3. Write a new class called LinkedPalindrome that uses the LinkedStack class rather than 4. Write a main method for LinkedPalindrome that tests several strings, both palindromes

Explanation / Answer

public class ArrayPalindrome {

ArrayStack One,Two,Three;

ArrayPalindrome()

{

One=new ArrayStack();

Two=new ArrayStack();

Three=new ArrayStack();

}

public boolean isPalindrome(String input)

{

int traverse=0;

boolean IsPalin=true;

for(int index=0;index<input.length();index++)

One.push(input.charAt(index));

for(int lastIndex=input.length()-1;lastIndex>=0;lastIndex--)

Two.push(input.charAt(lastIndex));

while(traverse<One.size())

{

if(One.pop()!=Two.pop())

IsPalin=false;

traverse++;

}

return IsPalin;

}

public static void main(String args[])

{

ArrayPalindrome Test=new ArrayPalindrome();

System.out.println("madam is Palindrom "+Test.isPalindrome("madam"));

System.out.println("Tree is Palindrom "+Test.isPalindrome("Tree"));

System.out.println("Madam is Palindrom "+Test.isPalindrome("Madam"));

System.out.println(" is Palindrom "+Test.isPalindrome(""));

System.out.println("A is Palindrom "+Test.isPalindrome("A"));

}

}

Above class is ArrayPalindrome .Please make sure that all the ArrayStack,LinkedStack And Stack interface should be in same package and you can test different String as well.

public class LinkedPalindrome {

LinkedStack One,Two,Three;

LinkedPalindrome() {

One=new LinkedStack();

Two=new LinkedStack();

Three=new LinkedStack();

}

public boolean isPalindrome(String input)

{

int traverse=0;

boolean IsPalin=true;

for(int index=0;index<input.length();index++)

One.push(input.charAt(index));

for(int lastIndex=input.length()-1;lastIndex>=0;lastIndex--)

Two.push(input.charAt(lastIndex));

while(traverse<One.size())

{

if(One.pop()!=Two.pop())

IsPalin=false;

traverse++;

}

return IsPalin;

}

public static void main(String args[])

{

LinkedPalindrome Test=new LinkedPalindrome();

System.out.println("madam is Palindrom "+Test.isPalindrome("madam"));

System.out.println("Tree is Palindrom "+Test.isPalindrome("Tree"));

System.out.println("Madam is Palindrom "+Test.isPalindrome("Madam"));

System.out.println(" is Palindrom "+Test.isPalindrome(""));

System.out.println("A is Palindrom "+Test.isPalindrome("A"));

}

}

Above class is LinkedStack.

Please let me know if some clarity is needed.

:) hope it helped