Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA: /** * CSCIProjectTwo: Use MyStack and MyQueue to write a project that check if a sentence is palindrom * * @author Your name

IN JAVA:

/** * CSCIProjectTwo: Use MyStack and MyQueue to write a project that check if a sentence is palindrom * * @author Your name * @version Date */ import java.util.Scanner; public class CSCI463ProjectTwo { public static void main(String [] args) { Scanner input = new Scanner(System.in); String sentence; String again; do{ System.out.println("Enter a sentence, I will tell you if it is a palindrome: "); sentence = input.nextLine(); if(isPalindrome(sentence)) System.out.println("\"" + sentence + "\" is a palindrome!"); else System.out.println("\"" + sentence + "\" is not a palindrome!"); System.out.println("Do you want another test (\"YES\" or \"NO\"): "); again = input.nextLine(); }while(again.equalsIgnoreCase("YES")); } /** * isPalindrom returns true if the given String is a palindrom * @ */ public static boolean isPalindrome(String sentence) { // declare a MyStack s // declare a MyQueue q for(int i = 0; i < sentence.length(); i++) { // if ith character in sentence is a letter // convert to upper case and push it into s and q } while(!s.isEmpty()){ // if the front of the queue not match the top of stack // return false // pop out top of the stack and front of the queue } return true; } }

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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions