Do My Homework / Homework Help Answers / Computer Science Homework Help / Write a program in C++ to determine if numbers are palindromes using a stack-based method for testing.

Write a program in C++ to determine if numbers are palindromes using a stack-based method for testing.

Need help with this question or any other Computer Science assignment help task?

Objective: Write a program to determine if numbers are palindromes using a stack-based method for testing. Program Description: Write a program that determines if a number is a palindrome. Recall that palindromes are strings (sequences of characters) that read the same forward or backward after punctuation and spacing is removed. The stack sample code that we discussed in class is a good starting point for this assignment. Note that the stack you will need to use is character-based. Consider converting the integer stack code to characters. Requirements: In addition to the functional description above, your solution also: • Must have the stack implemented as a linked list (class optional). You may use (extend) any code covered in lecture. You may not use the STL (Standard Template Library). • Must have the logic/implementation in a separate file from the stack implementation (an application file). • Must organize the source code files in accordance with the class standards. In other words, separate class declaration files (ADT header file), class implementation files (ADT implementation file), and application file.
Additional Instructions:
/* link.cpp * * Class for a sorted linked list of integers. */ #ifdef NOT_USING_CC_WHATEVER_ITS_PREDEF_IS #include #endif #include #include "link.h" // Add an item to the FRONT of the list void LinkedList::AddNode( int x ) { nodeptr n; // allocate new node n = new node; n->info = x; count++; if( start == NULL ) { start = n; n->next = NULL; } else { nodeptr tmp = start; n->next = tmp; start = n; } } //\end{verbatim} \lecpb \begin{verbatim} void LinkedList::DeleteNode( int x ) { nodeptr prev, curr; curr = start; while( curr != NULL && x > curr->info ) { prev = curr; curr = curr->next; } if( x == curr->info ) { if( curr == start ) start = start->next; else prev->next = curr->next; delete curr; count--; } } //\end{verbatim} \lecpb \begin{verbatim} int LinkedList::FirstNode() { return start->info; } void LinkedList::PrintNodes() { nodeptr p = start; while( p != NULL ) { cout info next; } } //\end{verbatim} \lecpb \begin{verbatim} #ifdef NOT_USING_CC_WHATEVER_ITS_PREDEF_IS bool LinkedList::IsInList(int x) #else int LinkedList::IsInList(int x) #endif { nodeptr p = start; while( p != NULL && x > p->info ) p = p->next; return (x == p->info); } int LinkedList::Size() { return count; }
/* link.h */ // This is a class for a linked list of integers. #ifndef LINK_H #define LINK_H #ifdef NOT_USING_CC_WHATEVER_ITS_PREDEF_IS #include #endif #include class LinkedList { private: struct node { int info; node * next; }; typedef node * nodeptr; nodeptr start; int count; //\end{verbatim} \lecpb \begin{verbatim} public: // Constructor LinkedList() { start = NULL; count = 0; } // Destructor ~LinkedList() { nodeptr p = start, n; while (p != NULL) { n = p; p = p->next; delete n; } } // Add a node onto the front of the linked list. void AddNode(int x); // Delete the first node found with the value x, if one exists. void DeleteNode(int x); // Return the first node found in the list int FirstNode(); // Output the values in the nodes, one integer per line. void PrintNodes(); // Return true if there in a node in the list with the value x. //bool IsInList(int x); int IsInList(int x); // Return a count of the number of nodes in the list. int Size(); }; #endif
There are no answers to this question.
Login to buy an answer or post yours. You can also vote on other others

Get Help With a similar task to - Write a program in C++ to determine if numbers are palindromes using a stack-based method for testing.

Related Questions

Similar orders to Write a program in C++ to determine if numbers are palindromes using a stack-based method for testing.
Popular Services
Tutlance Experts offer help in a wide range of topics. Here are some of our top services: