Develop a C++ program that reads a paragraph of text from a file. Tokenizes it such that each token is a word, determines whether a token is a palindrome (that is a word that reads the same forward and backward such as ‘madam’ or ‘1991’). Prints all palindrome and the total number of palindrome.Your source code shall consists at least three function apart from main(). Shows a program structure chart,flowchart,source code & output.
/*
C++ program that read an input file "DataFile.txt" .
Then call the functions to check if the words in the file are
palindromes. The program will display the list of the palindromes
and then count the of the palindromes in the file on console
output.
*/
#include <iostream>
#include<string>
#include <fstream>
#include <sstream>
using namespace std;
//function prototypes
string reverse(string &s);
bool isPalindrome(string word);
void displayPalindromCount(string whole_text);
int main()
{
/*Create an object of ifstream
class*/
ifstream inFile;
/*Open file for reading DataFile.txt file
*/
inFile.open("DataFile.txt");
if(!inFile)
{
cout<<"File is not
found"<<endl;
return EXIT_FAILURE;
}
/*Create a stringstream
object*/
stringstream strstream;
/*Read total file data into streamstring
object*/
strstream << inFile.rdbuf();
/*Convert the stringstream object to
string*/
string fileData = strstream.str();
/*Call the function, displayPalindromCount
with fileData */
displayPalindromCount(fileData);
//pause program output on console
system("pause");
return 0;
}
/*The function, displayPalindromCount that takes a
string
as argument and then find and display all the palindrome
strings and display the number of palindrome strings are
found on console output.*/
void displayPalindromCount(string whole_text)
{
int numPalindromes=0;
string word;
//read whole_text into stringstream object
stringstream data(whole_text);
cout<<"List of palindrome words from the
file \n"<<endl;
/*Split the data into words by space */
while(getline(data,word,' '))
{
//calling the funciton,
isPalindrome
if(isPalindrome(word))
{
/*print the
palindrome word */
cout<<(numPalindromes+1)<<"\t"<<word<<endl;
//increment the numPalindromes by 1
numPalindromes++;
}
}
//print the numPalindromes on console
output
cout<<"\nNumber of palindrome :
"<<numPalindromes<<endl;
}
/*The function isPalindrome that
takes a string word and return true
if the word is palindrom or returns false*/
bool isPalindrome(string word)
{
string reverse_word=reverse(word);
if(word==reverse_word)
return true;
else
return false;
}
/*The function reverse that takes a string and
reverse the string and returns the reverse string*/
string reverse(string &s)
{
string rev(s.rbegin(), s.rend());
return rev;
}
Sample Input file data: FileData.txt
Lorem Ipsum is simply dummy text of the printing and
typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever
since
the 1500s, when an jasmine unknown printer took galley of type and
scrambled
it to make type specimen madam book. It has survived 1991 not oyo
only five ono centuries,
but also the leap into electronic typesetting, remaining
essentially unchanged.
Sample Output:

Develop a C++ program that reads a paragraph of text from a file. Tokenizes it such...
A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. In this program, ask the user to input some text and print out whether or not that text is a palindrome. Create the Boolean method isPalindrome which determines if a String is a palindrome, which means it is the same forwards and backwards. It should return a boolean of whether or not it was a palindrome. Create the method reverse...
Write a program that reads each word from A1.txt and check if it's a palindrome or not. Show your output in the file Bl.txt. The total number of words in the file can change. You must use c-string or character arrays. Using String datatype and strrev() function are not allowed in this problem. "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward." (Wikipedia) Sample Input: series madam Sample Output: yes
In C++ Write a program that: Gets a string from cin Prints TRUE if the string is a palindrome, FALSE otherwise, all uppercase, followed by endl. Palindrome reads the same backward as forward, e.g., madam.
Write a C Program that asks the user to input a string and then the user is prompted back whether the input string is a “Palindrome Word” or not. (A Palindrome Word reads the same backward or forward, eg. madam, racecar, etc.) Your program should contain a function that accepts the input string from the main function and returns a value indicating whether the input string is a Palindrome or not. Use Pointers to traverse the string.
Complete the printPalindrome method in the provided Palindrome.java program. The printPalindrome method accepts a String as a parameter and prints whether the parameter String is a palindrome (i.e., reads the same forwards as it does backwards, for example, "abba" or "racecar"). Make the code case-insensitive, so that words like "Abba" and "Madam" will be considered palindromes. import java.util.*; /** * Determines if a user entered String is a palindrome, which means the String * is the same forward and reverse....
write a C++ program that reads in a text file and reads each character or lexemes and states what token it is and writes to another file for example: while (fahr < upper) a = 23.00 whileend Output: token lexeme -------------------------------- keyword while separator ( identifier fahr operator < identifier upper separator ) identifier a operator = real 23.00 keyword whileend the program aslo reads in comments but does not add to the list. characters that are commented out or...
Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...
A palindrome is a number or a text phrase that reads the same backward as forward. For example, each of the following six-digit integers is a palindrome: 123321, 555555, 455554, and 116611. Write a pseudocode and C++ program that reads in a six-digit integer and determines whether or not it is a palindrome. You must use the division and remainder operators. Assume input is correct (six-digit integer). Please don't use loops. Do it with only using if else.
C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member functionbool isPalindrome( )that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main...
C++ Programming Palindrome Detector: A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man,a plan, a canal, Panama Desserts, I stressed Kayak Write a book function that uses recursion to determine if a string argument is a palindrome. The function should return true if the argument reads the same forward and backward. Demonstrate the function in a program, which continues to...