Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The files easytest.dat _____________________________________________________________________________________________________________________________________________________ Bob Turkey or Tofu? dad Choose Gratitude noon Hard work has its rewards MOM What goes around comes around. Never odd

The files easytest.dat

_____________________________________________________________________________________________________________________________________________________

Bob Turkey or Tofu? dad Choose Gratitude noon Hard work has its rewards MOM What goes around comes around. Never odd or even Will a hyphe-nated word throw you off? Stressed desserts

_____________________________________________________________________________________________________________________________________________________

and hardertest.dat

_____________________________________________________________________________________________________________________________________________________

Bob Not a pallindrome dad Choose Gratitude noon Hard work has its rewards MOM What goes around comes around. Never odd or even Will a hyphe-nated word throw you off? Stressed desserts A nut for a jar of tuna. Al lets Della call Ed Stella. Amore, Roma. Are we not pure? No, sir! Panamas moody Noriega brags. It is garbage! Irony dooms a mana prisoner up to new era. Borrow or rob? Taco cat Was it a car or a cat I saw? Dennis, Nell, Edna, Leon, Nedra, Anita, Rolf, Nora, Alice, Carol, Leo, Jane, Reed, Dena, Dale, Basil, Rae, Penny, Lana, Dave, Denny, Lena, Ida, Bernadette, Ben, Ray, Lila, Nina, Jo, Ira, Mara, Sara, Mario, Jan, Ina, Lily, Arne, Bette, Dan, Reba, Diane, Lynn, Ed, Eva, Dana, Lynne, Pearl, Isabel, Ada, Ned, Dee, Rena, Joel, Lora, Cecil, Aaron, Flora, Tina, Arden, Noel, and Ellen sinned. Ed, I saw Harpo Marx ram Oprah W. aside. Madam, in Eden, Im Adam. Murder for a jar of red rum. Oozy rat in a sanitary zoo. Yo, banana boy! _____________________________________________________________________________________________________________________________________________________

(posted on Canvas) contain some number of words/phrases (one per line) to be evaluated to see if each one is a palindrome or not. A palindrome is a word or phrase that reads the same from right to left as it does from left to right. For example: the words Bob, dad, noon, MOM are palindromes; the phrases Never odd or even, Stressed desserts are palindromes.

In C++, create a stack class, and use the stack class to help you solve the above problem. Your stack class needs to implement the stack using a dynamically allocated array. Make sure to look at the SimpleList Example code.

_____________________________________________________________________________________________________________________________________________________

/******

ideone.com/41LFjF SimpleList CORRECT

*****/

#include using namespace std;

class SimpleList { public: SimpleList(); SimpleList(const SimpleList& ); ~SimpleList(); const SimpleList& operator=(const SimpleList & right);

void printList()const; void clear(); void add(int newItem); bool member(int anItem)const; int currentSize() const; private: //void makeLarger(); int * listptr; int size; int maxSize; };

int main() { SimpleList myList; myList.add(3); SimpleList secondList = myList; myList.add(4); secondList = myList; myList.add(5); myList.printList(); secondList.printList(); return 0; } SimpleList::SimpleList() { cout << "In null constructor" << endl; listptr = nullptr; size = 0; maxSize = 10; listptr = new int[maxSize]; } SimpleList::SimpleList(const SimpleList& orig) { cout << "In copy constructor" << endl; maxSize = orig.maxSize; listptr = new int[maxSize]; size = orig.size; for(int i = 0; i

In null constructor In add In copy constructor In add In assignment operator In add 3 4 5 3 4 Destructor here Destructor here

_____________________________________________________________________________________________________________________________________________________

That program illustrates the basics of working with a dynamically allocated array within a class. It also shows the start of how to work with a resize() or makeLarger() member function.

Additionally your program should:

  • Ask the user for the name of a file
  • Read in the file, one line at a time, and display the word/phrase (in the same case as the original) and whether or not it is a palindrome.
  • When done with the file, display the number of palindromes found.
  • Offer to do the job again on another file.
  • Repeat the above until the user chooses to quit.

Your program must use your own stack class to determine if a word/phrase is a palindrome. You are NOT allowed to use the stack in C++ standard template library (STL).

Grading

The assignment will be graded in accordance with the Labs and Programming Assignment Expectation handout, formatting.txt example, and the "Programming Process CPSC1430 document and the rubric posted on Canvas. Failure to adhere to the guidelines could result in losing points.

Submitting your Program

You must submit three files:

  • The header file: Stack.h
  • The implementation file: Stack.cpp
  • The driver program: hw4.cpp

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

How do theories of economics change over time?

Answered: 1 week ago

Question

Which described qualities do you agree with?

Answered: 1 week ago

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago