Question

Create a data file named REVERSE.TXT and type the sentence                        EVERY GOOD BOY & GIRL...

Create a data file named REVERSE.TXT and type the sentence      

                 EVERY GOOD BOY & GIRL DOES FINE                

                                                                

Write a C++ program that retrieves the phrase stored in the    

  the data file REVERSE.TXT and immediately displays the phrase   

on the screen. Then your program displays the phrase where   

  each word is reversed. Notice you’re not reversing the entire

sentence. The order of the words remains the same. However,   

the spelling of each word is reversed!

EXAMPLE: For this data file, your output would be:           

                 EVERY GOOD BOY & GIRL DOES FINE                

                 YREVE DOOG YOB & LRIG SEOD ENIF   

NOTE: You must write your program in a general way so that if

        the text of the phrase stored in REVERSE.TXT was changed,

        the program would reverse the spelling of each word.   

EXAMPLE:                                                      

    If REVERSE.TXT stored:   TO BE OR NOT TO BE                   

     This would display:   OT EB RO TON OT EB                   

                                                                

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

#include<iostream>
#include<fstream>
#include<string>
using namespace std;
string reverse(string str)
{
   string ans="";
for (int i=str.length()-1; i>=0; i--)
ans+=str[i];
return ans;
}
int main()
{
   ifstream inFile;
   string word;
   inFile.open("REVERSE.txt");
   if(!inFile)
   {
       cout<<"Unable to open the file . Exiting!!!"<<endl;
       return 0;
   }
   while(inFile>>word)
   {
       cout<<reverse(word)<<" ";
   }
   cout<<endl<<endl;
   return 1;
}
ouptus

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
Create a data file named REVERSE.TXT and type the sentence                        EVERY GOOD BOY & GIRL...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class called cStringManipType that has 2 functions:       1. Displays an entire c-string reversed                    &nbs

    Create a class called cStringManipType that has 2 functions:       1. Displays an entire c-string reversed                          2. Displays a c-string where every word is reversed NOTE: Additional functions may be included in the class such                   getCstring which would have the user enter a sentence.    In main declare two objects of the class, get two sentences    and then display each one completely in reverse and finally    display each sentence with every word reversed    EXAMPLE: If the...

  • Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin....

    Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin.” The rules used by Pig Latin are as follows: • If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay". • If it begins with a consonant, then we take all consonants before...

  • c++ program Notes 1. Your program should use named string constant for the file name to open the file. Do not add any pa...

    c++ program Notes 1. Your program should use named string constant for the file name to open the file. Do not add any path to the file name because the path on your computer is not likely to exist on the computer the instructor uses to grade the program. Points may be deducted if you don't follow this instruction. 2. Split statements and comments longer than 80 characters into multiple lines and use proper indentations for the split portions. 3....

  • Python program This assignment requires you to write a single large program. I have broken it...

    Python program This assignment requires you to write a single large program. I have broken it into two parts below as a suggestion for how to approach writing the code. Please turn in one program file. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of...

  • 1. Expense Pie Chart Create a text file that contains your expenses for last month in...

    1. Expense Pie Chart Create a text file that contains your expenses for last month in the following categories: -Rent -Gas -Food -Clothing -Car Payment -Misc Write a Python program that reads the data from the file and uses matplotlib to plot a pie chart showing you how you spend your money. 2. 1994 weekly gas graph The text file named 1994_Weekly_Gas_Averages.txt contains the average gas price for each week in the year 1994. (There are 52 lines in the...

  • C++ program: can you help create a autocorrect code using the cpp code provided and the...

    C++ program: can you help create a autocorrect code using the cpp code provided and the words below using pairs, vectors and unordered map: Objectives To practice using C++ std::pair, std::vector, and std::unordered_map To tie together what we've learned into the context of a real-world application used by millions of people every day Instructions For Full Credit You're given a short list of words in known_words_short.txt that contains a handful of very different words. Assume this short list of words...

  • In this assignment you’ll implement a data structure called a trie, which is used to answer...

    In this assignment you’ll implement a data structure called a trie, which is used to answer queries regarding the characteristics of a text file (e.g., frequency of a given word). This write-up introduces the concept of a trie, specifies the API you’re expected to implement, and outlines submission instructions as well as the grading rubric. Please carefully read the entire write-up before you begin coding your submission. Tries A trie is an example of a tree data structure that compactly...

  • Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that...

    Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that work with text files is the problem of locating a specific substring within the file. I am sure we’ve all done this many times when working with Word, Notepad, or other editors. Since we don’t have a GUI or other means of displaying the contents of a file all at once, let’s modify the problem slightly. Rather than locating a specific substring within a...

  • IN PYTHON PLEASE...... Process bowlers and their 3 bowling scores. Use my data file below: bowlers2.txt...

    IN PYTHON PLEASE...... Process bowlers and their 3 bowling scores. Use my data file below: bowlers2.txt ( Showed below) And you can also use a while loop to read your file if you prefer. How to average down an array, which you don’t have to do. In this case that would be the game 1 average for all bowlers for example. Find the low average and high average. Start with read the data into arrays/lists and printed out the arrays/lists...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT