Question

In: Computer Science

PLEASE do the following problem in C++ with the screenshot of the output. THANKS! Assuming that...

PLEASE do the following problem in C++ with the screenshot of the output. THANKS!

Assuming that a text file named FIRST.TXT contains some text written into it, write a class and a method named vowelwords(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel (i.e., with 'a', 'e', 'i', 'o', 'u'). For example, if the file FIRST.TXT contains Carry umbrella and overcoat when it rains Then the file SECOND.TXT shall contain umbrella and overcoat it.

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

#include<iostream>

#include<fstream>

using namespace std;

//required class containing methods

//change the class name as you like

class VowelsFinder{

                //variables to store names of input and output file

                string input, output;

                public:

                //constructor

                VowelsFinder(){

                                //initializing file names

                                input="FIRST.TXT";

                                output="SECOND.TXT";

                }

               

                //method to extract words from input file, write to output file all words that start with

                //lower case vowel.

                void vowelwords(){

                                //opening input file

                                ifstream inFile(input.c_str());

                                //checking if file opened correctly, displaying error and exiting if not opened

                                if(!inFile){

                                               cout<<"cannot find "<<input<<endl;

                                               return;

                                }

                                //doing the same for output file

                                ofstream outFile(output.c_str());

                                if(!outFile){

                                               cout<<"cannot create "<<output<<endl;

                                               return;

                                }

                                string word;

                                //looping and reading each word from input file one by one. assuming words are

                                //separated by space or tabs

                                while(inFile>>word){

                                               //finding first letter

                                               char c=word[0];

                                               //checking if it is a lower case vowel

                                               if(c=='a' || c=='e'|| c=='i' || c=='o' || c=='u'){

                                                               //writing to output file, separated by space

                                                               outFile<<word<<" ";

                                               }

                                }

                                //closing both files

                                inFile.close();

                                outFile.close();

                }

};

int main(){

                //creating an object of the above class

                VowelsFinder vowelsFinder;

                //calling vowelwords. if everything works correctly, the system will not display any

                //output, but creates the output file as needed.

                //make sure you have FIRST.TXT file in same directory.

                vowelsFinder.vowelwords();

                return 0;

}

/*FIRST.TXT file screenshot*/

/*SECOND.TXT file screenshot (after running the program)*/


Related Solutions

Please in C++ thank you! Please also include the screenshot of the output. I have included...
Please in C++ thank you! Please also include the screenshot of the output. I have included everything that's needed for this. Pls and thank you! Write a simple class and use it in a vector. Begin by writing a Student class. The public section has the following methods: Student::Student() Constructor. Initializes all data elements: name to empty string(s), numeric variables to 0. bool Student::ReadData(istream& in) Data input. The istream should already be open. Reads the following data, in this order:...
C++(screenshot output please) Part 2 - Tree programs Program 1 Implement a tree using an array...
C++(screenshot output please) Part 2 - Tree programs Program 1 Implement a tree using an array Program 2 Implement a tree using linked list - pointer Binary Tree Program 3 - Convert program 1 to a template
Please in C++, show screenshots of output plus .txt file. thanks Breakfast Billing System Write a...
Please in C++, show screenshots of output plus .txt file. thanks Breakfast Billing System Write a program to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right...
Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created:...
Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created:    1. Artist.java (Given Below)    2. p7artists.java (Input file to read from)    3. out1.txt (Output file to write to) B. Java programs needed to writeand create:    1. MyArtistList.java:    - Contains the following:        1. list - public, Arraylist of Artist.        This list will contain all entries from "p7artists.txt"        2. Constructor:        A constructor that accepts one...
Define a problem with user input, user output, -> operator and destructors. C ++ please
Define a problem with user input, user output, -> operator and destructors. C ++ please
PLEASE DO IN C++ AND USE REPL TO WRITE CODE The following problem statement is based...
PLEASE DO IN C++ AND USE REPL TO WRITE CODE The following problem statement is based on a problem in the C++ text by Friedman & Koffman: The results of a survey of the households in your township are available for public scrutiny. Each record (struct-type entity) contains input data for one household, including a four-digit integer identification number the annual income for the household the number of household members. Assuming that no more than 25 households were surveyed, write...
Please do on excel and screenshot with formulas. You are examining the desirability of selling widgets....
Please do on excel and screenshot with formulas. You are examining the desirability of selling widgets. To conduct the analysis, you’ve estimated that you will sell 1 million units and will sell the units for $99 each for the next five years. The variable costs for producing this product is estimated to be $32 per unit. Fixed costs will be $3 million per year. The equipment used to produce the widgets will cost $20 million and will be depreciated using...
Please do MC thanks. 10. Which of the following is/are INCORRECT for the BOD test? (a)...
Please do MC thanks. 10. Which of the following is/are INCORRECT for the BOD test? (a) Long time necessary to get results (b) Only biodegradable organic matter can be measured (c) Acclimated seed needed to get meaningful results (d) Pre-treatment like dilution may be necessary for toxic wastes and nitrifying conditions (e) None of the above 4 11. Find the theoretical TOC of 120 g/L glucose (C6H12O6) solution [Given molar mass of C=12, O=16, H=1]. (a) 12 g/L (b) 24...
Please do this in C++ only. Please Show your code and your output too. Would you...
Please do this in C++ only. Please Show your code and your output too. Would you focus on number 2 in the Required functions:? Please use all the variables in the program. The assignment problem: You are asked to develop an application that prints a bank’s customers' names, IDs, and accounts balances in different ways. In this program, you need to read a file of customer’s data into different arrays, pass these arrays to functions as (array parameter), calculate the...
I want to understand how this can be solved in c++. Please send a screenshot also...
I want to understand how this can be solved in c++. Please send a screenshot also with your code so I can see how it is supposed to be formatted or indented. Instructions: Your program will read in a file of commands. There are three types of commands: Warrior creates a new warrior with the specified name and strength. Battle causes a battle to occur between two warriors. Status lists all warriors, alive or dead, and their strengths. A sample...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT