Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain each line in detail and what is happening in the code as well so that i may understand what is happening. The out

Please explain each line in detail and what is happening in the code as well so that i may understand what is happening. The out put must be exactly the same as the photo below.

image text in transcribed

image text in transcribed

Please DO NOT CHANGE these files:

1. StackInterface.java 2. PalindromeChecker.java - Do not change the "main" method. - Please ADD CODE to complete implementing the program.

---------------------------------------------------------------------- OurStack.java -----------------------------------------------------

public class OurStack implements StackInterface { public OurStack() { } @Override public void push(T newEntry) { } @Override public T peek() { } @Override public T pop() { } @Override public boolean isEmpty() { } @Override public void clear() { } }

-------------------------------------------------------------- PalindromeChecker.java-----------------------------------------

import java.util.Scanner; // // - Do not change the "main" method. // - Please ADD CODE to complete implementing the program // public class PalindromeChecker { private static boolean isPalindrome(String string) { } // // - Do not change the "main" method. // - Please ADD CODE to complete implementing the program // public static void main(String[] args) { // // - Do not change the "main" method. // - Please ADD CODE to complete implementing the program // Scanner input = new Scanner(System.in); System.out.print("[>>] Enter a string (or a ! to exit): "); String string = input.nextLine(); while (!string.equals("!")) { if (isPalindrome(string)) { System.out.println(" [+] Yes. \"" + string + "\" IS a palindrome!"); } else { System.out.println(" [-] No. \"" + string + "\" is NOT a palindrome!"); } System.out.print("[>>] Enter a string: "); string = input.nextLine(); } System.out.println("[ 

------------------------------------------------------------------------ StackInterface.java ---------------------------------------------------------

public interface StackInterface { public void push(T newEntry); public T pop(); public T peek(); public boolean isEmpty(); public void clear(); } 

PART B - Stack, 15 points Please add code to the provided code. Our program tests whether an input string is a palindrome. Our program output must be identical to this sample output A palindrome is a string of characters (a word, phrase, or sentence) that is the same regardless of whether we read it forward or backward. For example, Race car is a palindrome. So is A man, a plan, a canal: Panama. More about palindromes: http://www.palindromelist.net/. We ignore spaces [>>] Enter a string (or a ! to exit): Csc [+] Yes. "Csc" IS a palindrome! [>>] Enter a string: CSC 220 - Data Structures [-] No. "CSC 220 - Data Structure" is NOT a palindrome ! [>>] Enter a string: Ah, Satan sees Natasha! [+] Yes. "Ah, Satan sees Natasha!" IS a palindrome! [>>] Enter a string: Amy, must I jujitsu my ma? [+] Yes. "Amy, must I jujitsu my ma?" IS a palindrome! [>>] Enter a string: A man, a plan, a canal: Panama. [+] Yes. "A man, a plan, a canal: Panama." IS a palindrome! [>>] Enter a string: Are Mac 'n' Oliver evil on camera? [+] Yes. "Are Mac 'n' Oliver evil on camera?" IS a palindrome! [>>] Enter a string: ! [

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions