Question: C++ Stack Queue Palindrome Write a program that reads a line of text from input and output file, changes each uppercase letter to lowercase, and

C++ Stack Queue Palindrome

Write a program that reads a line of text from input and output file, changes each uppercase letter to lowercase, and places each letter both in a queue and into a stack. The program should then verify whether the line of text is a palindrome (a set of letters or numbers that is the same whether read forward or backward).

ToDo: read from input file ignore spaces? y/n * then read line using getline_portable(), * that allows to reach the whole line and remove ' * if it is at the end of the line * then, depends on ignoreSpaces y or n * read line, make it lower cases * determine if the line palindrome or not * read line by line until reach word "end", then stop reading * output line by line, enclosed in {} id line is palindrome or not.

input file in.txt corresponds output file out.txt

input file in2.txt corresponds output file out2.txt

Stub program is provided. Complete ToDos

DriverPalindrom.cpp

#include

#include

#include

#include

#include

using namespace std;

istream& getline_portable(istream& is, string& str) {

istream& ris = std::getline(is, str);

if (str.size() && str[str.size() - 1] == ' ')

str.resize(str.size() - 1);

return ris;

}

int main()

{

ifstream fin;

ofstream fout;

string fileNameI, fileNameO;

const string endOfData = "end";

cout << "Enter input and output fileNames: ";

cin >> fileNameI >> fileNameO;

fin.open(fileNameI.c_str());

fout.open(fileNameO.c_str());

stack s;

queue q;

char c;

string str;

string ignoreSpaces;

getline(fin, ignoreSpaces);

cout << "Ignore spaces = " << ignoreSpaces << " ";

bool a = true;

getline(fin, str);

int len = str.length();

/*

* LOOP

* use stack s and queue q

cout<<"Inputed line {"<

fout<<"Inputed line {"<

OR

cout<<"Inputed line {"<

fout<<"Inputed line {"<

}

*/

cout << "-----TODO the program ";

fout << "-----TODO the program ";

fin.close();

fout.close();

system("pause");

}

Input and output files to be used: https://drive.google.com/drive/folders/1qFa9UanRYMfM8GoIRy9px5kpjOq_i5sG?ogsrc=32

Sample Output:

enter input and output fileNames: in.txt out.txt

ignore spaces = y

Inputed line {abba} is a palindrome

Inputed line {ab bA} is a palindrome

Inputed line {An N a} is a palindrome

Inputed line {An NA} is a palindrome

Inputed line {helicoptor} is not a palindrome

Inputed line {something very important} is not a palindrome

enter input and output fileNames: in2.txt out2.txt

ignore spaces = n

Inputed line {abba} is a palindrome

Inputed line {ab bA} is a palindrome

Inputed line {An N a} is not a palindrome

Inputed line {An NA} is a palindrome

Inputed line {helicoptor} is not a palindrome

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!