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

This is C++, please insert screenshot of output please. Part1: Palindrome detector Write a program that...
This is C++, please insert screenshot of output please. Part1: Palindrome detector Write a program that will test if some string is a palindrome Ask the user to enter a string Pass the string to a Boolean function that uses recursion to determine if something is a palindrome or not. The function should return true if the string is a palindrome and false if the string is not a palindrome. Main displays the result ( if the string is a...
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...
3. Add mutex locks to tprog2.c to achieve synchronization, and screenshot the output tprog2.c #include <stdio.h>...
3. Add mutex locks to tprog2.c to achieve synchronization, and screenshot the output tprog2.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> void* print_i(void *ptr) { printf("1: I am \n"); sleep(1); printf("in i\n"); } void* print_j(void *ptr) { printf("2: I am \n"); sleep(1); printf("in j\n"); } int main() { pthread_t t1,t2; int rc1 = pthread_create(&t1, NULL, print_i, NULL); int rc2 = pthread_create(&t2, NULL, print_j, NULL); exit(0); }
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 INCLUDE THE SOURCE CODE AND OUTPUT PLEASE AND THANKS!!This assignment covers recursion and linked list...
PLEASE INCLUDE THE SOURCE CODE AND OUTPUT PLEASE AND THANKS!!This assignment covers recursion and linked list which include the following tasks: 2. a. Using C/C++, construct a single linked list of 8 nodes and assign random numbers as the nodes’ values. Then print the list from the first node to the last. Finally, free all memories of the linked list. b. Using C/C++, construct a single linked list of 8 nodes and assign random numbers as the nodes’ values. Then...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT