Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello below are the following traks I need implemented for the three codes below. One is the main cpp and the two are .h. Please

Hello below are the following traks I need implemented for the three codes below. One is the main cpp and the two are .h. Please answer in c++ and help solve the Boolean isPalindrome function

Use ArrayList to implement MyStack class which define the data structure that has Last In First Out property

Use ArrayList to implement MyQueue class which define the data structure that has First In First Out property

Write a function public static Boolean isPalindrome(String sentence) This function returns true if sentence is a palindrome; false otherwise.

Main CPP:

#include  #include  #include  #include "MyStack.h" #include "MyQueue.h" using namespace std; bool isPalindrome(string sentence); int main(){ string sentence; char choice; do{ cout <<"Enter a sentence: "; getline(cin, sentence); cout << "\"" << sentence << "\""; if(isPalindrome(sentence)) cout << " is a palindrome" << endl; else cout << " is NOT a palindrome" << endl; cout << "Do you want to make another check? Y/N :"; cin >> choice; // get input char cin.ignore(); // ignore new lines }while(choice == 'y' || choice == 'Y'); cout << "Thanks for choose the "; return 0; } bool isPalindrome(string sentence){ // you implement this }

MyStack.h:

#ifndef MyStack_h #define MyStack_h #include  #include  using namespace std; template class MyStack{ public: MyStack(); void push(T item); T pop(); T peek() const; // const means that the function will not change the content of the object int size() const; bool isEmpty() const; private: vector v; // use a vector to hold data in stack }; #include "MyStack.cpp" #endif /* MyStack_hpp */
MyQueue.h:
#ifndef MyQueue_h #define MyQueue_h #include  #include  using namespace std; template class MyQueue{ public: MyQueue(); T pop(); void push(T item); T peek() const; int size() const; bool isEmpty() const; private: list q; // we use a list to hold data for queue }; #include "MyQueue.cpp" #endif /* MyQueue_hpp */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions