QuestionQuestion

The palindrome.cpp program - C++ simple program, runable over some online compiler

A palindrome = character string that reads the same backward as forward when ignoring letter spacing, punctuation, and uppercase and lowercase letters.
Examples:
1. The word "Level"
2. The sentence Napoleon said when he went into exile on Elba.
"Able was I, ere I saw Elba".
Write an interactive program that repeatedly prints out its menu to the user on the screen and, at one of its options, reads the string from the keyboard and decides whether it is a palindrome or not.Result prints out on monitor. Include the following user interaction options:
and .... Create two new and empty stacks
// this is called only once at the beginning of the program
b ... Empty the contents in both stacks
c ... Load a new string from the keyboard into the first stack and create a second stack
d ... Print out the contents of the first stack
e ... Print out the contents of the second stack
// the second stack contains the input string in reverse order
f ... Determines whether the string is a palindrome
x ... Exit the program.
Entering this program is one of the above-mentioned options a-f, x typed by the user via the keyboard within an infinite loop until the user exits the program via the 'x' option.
After loading the option, the program performs the corresponding operation and prints its output to the monitor and to the text file "vystup.txt".
Use of classes in C ++ and the <iostream.h> header file for keyboard input is required. <fstream.h> to output the file. The main data structure of the program will be the ADT stack exactly as specified below. Its specification will be located in the header file: stack.h and its implementation in the file: stack.cpp. In addition, the data (private) part of the stack will contain a string implemented as an array of length 21 characters. After loading the program, the string is written to the first stack. Then, using the contents of the first stack, the string is also written to the second stack in reverse order. Only the stack operations specified in the file stack.h must be used when working with the stack. Particular attention will be paid to the overflow and underflow of the stack. These cases will be treated with the appropriate error
reports. The program will be designed as an object
oriented and must be functional, and tested within its main program, palindrome.cpp.
Assume that the input string consists only of the letters of the English alphabet, possibly spaces and punctuation, as shown in the introductory examples.

(program files: "stack.h", "stack.cpp" and "palindrome.cpp", "vystup.txt")

stack specification:
LIFO stack will operate in context last-in first-out,
where elements are inserted and extracted only from one end of the container.
allowed operations:
Create (), IsEmpty(), IsFull(),
Push (ItemType e), Top (), Pop ()

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include"stack.h"
string input;
Stack stack1;
Stack stack2;
bool stacksCreated;

/**
* this function show an interactive menu to the user
*/
void showMenu();

/**
* this method write the corresponding operation
* output to the text file "vystup.txt".
* @parm message that will print to the text file "vystup.txt".
*/
void writeToFile(string);

/**
* this method create two new and empty stacks
*/
void createStacks();

/**
* this method clear the contents of both stacks
*/
void emptyStacks();

/**
* this fuction get the string from the keyboard
* and send that string to checkPalindrome
* to decide that this string is Palindrome or not
*/
void readString();

/**
* this function print the content of stack1 to the console
*/
void printFirstStack();

/**
* this function print the content of stack2 to the console
*/
void printSecondStack();

/**
* this function check if that string is
* Palindrome or not
* and print the result out on monitor
* @parm user input
*/
void checkPalindrome();


int main(){
showMenu();
}

/**
* this function show an interactive menu to the user
*/
void showMenu(){
char repeate...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats