
Concept explainers
Using OOP, write a C++ program that read an input file and keep an array of counters for the number of letters in each word in the input file.
The input file name is Poem.txt and is located in the current directory.
The program will define an array of 9 elements stored in the private member variable area of the class:
- the 0 element will hold the number of words that are 1 letter long
- the 1 element will hold the number of words that are 2 letters long
- the 2 element will hold the number of words that are 3 letters long
- the 3 element will hold the number of words that are 4 letters long
- ....and so on until the 8 element will hold the number of words that are 9 letters long.
The program will read in the contents of the file word by word into a string variable. The program will determine the length of the word - not counting punctuation - and add to the counter stored in the element array that holds that number of letters in length.
So, if the word "midnight" is read in, the number of letters in this word is 8. The array element counting the number of 8 letter words is incremented by 1. Be mindful that "midnight," (comma at the end) and "midnight -", (hyphen) is still counted as 8 letters. Do not count any punctuation as part of the word. This includes commas, semi-colons, periods, hyphens, question marks, etc...
Add a header and closing statement as shown in the example below.
When the file is opened, add an output statement indicating the file is being opened.
When the file is starting to be processed word by word, add an output statement indicating the file is being processed.
When the end of file is reached, display the contents of the array as shown in the example below.
When the file is being closed, add an output statement indicating the file is closed.
The class should use appropriate private member variables and methods.
An Example:
if the contents of the input file contained this line: Once upon a midnight dreary, while I pondered, weak and weary.

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images

I need to not using "namespace std" in the code. Could you use an alternative to it
I need an extra line to display the total number of words in the input file and beginning and ending statements
I need to not using "namespace std" in the code. Could you use an alternative to it
I need an extra line to display the total number of words in the input file and beginning and ending statements
- Write a function named swapFrontback that takes as input an array ofintegers and an integer that specifies how many entries are in the array. Thefunction should swap the first element in the array with the last elements inthe array. The function should check if the array is empty to prevent errors.The header file for the swapFrontback() is:swapFrontback.h:double swapFrontback (int [] arr,int size);Write a driver (main.c) to test your function with arrays of different lengthand with varrying front and back numbers. Print the array elements beforeand after the swap in the main.c.Sample Run: Original Array: 1 2 3 4 5 6 FrontBack Array: 6 2 3 4 5 1arrow_forwardWritten in Python with docstring please if applicable Thank youarrow_forwardWrite a C++ program, you will create a class called Books to hold the information about the books in a library. The information required for each book is as follows Book Title Author name Publisher Publish year Subject Book ID (identical 5 digits’ number) Implement the following getBookInfo () member function that receives a pointer to a book and fills it up with user data. User input validation is necessary. The user should be properly prompted for each field. void getBookInfo (Books *b) Implement the following printBookInfo () member function. void printBookInfo (Books *b) Your function should print the book in the following format: Book Title : Object Oriented Programming Using C++ Author : Chris M. Szalwinski Publisher : Amazon Year : 2016 Subject : Computer Science Book Id : 00034 Note: You need to add required constructors/destructors, member functions or data members/variables in your program to complete its execution. //Missing lines of codes to be completed by the student }…arrow_forward
- The header record of a batch file contains totals of items in the file. Each time the file is processed, the totals are also updated. Nightly, after the batch processes, the relevant data fields are summed and compared with the totals. Unbalanced conditions are reported and corrected. This example describes: a) Segregation of duties b) Application output control c) Application edit check d) Applicaiton input controlarrow_forwardIn C# Use a one-dimensional array to solve the following problem. Write a class called ScoreFinder. This class receives a single dimensional integer array representing passer ratings for NFL players as an argument for its constructor. The test class will provides this argument. The test class then calls upon a method from the ScoreFinder class to start the process of finding a specific rating, which will be provided by the user. The method will iterate through the array and find any matching values. For all the matches that are found, the method will note the index of the cell along with its value. At completion, the method will print a list of all the indices and the associated scores along with a count of all the matching values.arrow_forwardIn C++ Create a class called Student. Each student should have a name and ID number (an int). They should also have a ptr to a dynamic array called Grades. The public methods for Student should be: getName, setName, getID, setID, setGrades, getGrades. In the constructor you should initialize Grades to be an array of size 4 with the values 0 for each position. Make sure that you use THIS properly. Create 2 students, assign one object to another and show that when you assign grades to one it effects the other equally.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





