Question: Hi, please help me code this question. I am attaching the question along with the conditions that the program will check this code, all are

Hi, please help me code this question. I am attaching the question along with the conditions that the program will check this code, all are screen shots. Thank youHi, please help me code this question. I am attaching the questionalong with the conditions that the program will check this code, allare screen shots. Thank you 6.10 Assignment Part 3: Word Filter Inthis lab you will write a program that reads in a textfile containing a list of words, and writes two text files; onecontaining words with an even number of characters, the other containing wordswith an odd number of characters. The program should begin by promptingthe user for the name of the input file. Validate the filenameto make sure it ends in .txt. If it does not, re-prompt

6.10 Assignment Part 3: Word Filter In this lab you will write a program that reads in a text file containing a list of words, and writes two text files; one containing words with an even number of characters, the other containing words with an odd number of characters. The program should begin by prompting the user for the name of the input file. Validate the filename to make sure it ends in .txt. If it does not, re-prompt the user after printing an informative message. For example: Enter the name of the input file: words.doc Only filenames ending in '.txt' are accepted! Enter the name of the input file: The program should attempt to open the file for reading. If there is an error (for example, if the file does not exist), then the program should output an error message and exit (by returning 1 from main()). For example: Enter the name of the input file: no_such_file.txt Failed to open file for read: no_such_file.txt Assuming the file opens successfully, the program should prepare the two output files. These files should be named: -even.txt . -odd.txt where is the filename up to, but not including, .txt For example, if the user enters words.txt as the input file name, the corresponding output file names will be words-even.txt and words-odd.txt. The program should now use a while loop to read in the words, count the number of characters, and write the words to the appropriate output file, each word on a separate line. Keep counts of how many words are read and written so that you can output a summary at the end. As an example, suppose the input file is numbers.txt which contains: one two three four five six seven eight nine ten The result of a program run should look like this: Enter the name of the input file: numbers.txt 10 words read in from numbers.txt 3 words written to numbers-even.txt 7 words written to numbers-odd.txt The program should generate numbers-even.txt: four five nine and numbers-odd. txt: one two three six seven eight ten Hints: 1) Use a while loop to validate the filename input. 2a) Use .find() to locate the position of ".txt" in the filename. 2b) Remember, the special value string:: npos is returned from .find() if there is no match. 3) The .insert() method inserts a substring into a string at a given index. 4) The .size() (or.length()) method can be used to determine the length of a string. 5) The mod (%) operator can be used to determine if a number is even or odd. 295532.1772524 LAB ACTIVITY 6.10.1: Assignment Part 3: Word Filter Submission Instructions Downloadable files main.cpp, words-1.txt words-3.txt numbers.txt words-2.txt Download Compile command g++ main.cpp -Wall -o a.out We will use this command to compile your code Upload your files below by dragging and dropping into the area or choosing a file on your hard drive. main.cpp File added Remove 1: Filename Validation ~ 1/1 Input words.doc words.txt Your output Enter the name of the input file: Only filenames ending in '.txt' are accepted! Enter the name of the input file: Failed to open file for read: words.txt 2: Words 1 Summary ^ 0/1 sh: 1: pause: not found Input words-1.txt Your output Enter the name of the input file: 20 words read in from words-1.txt 11 words written to words-even.txtwords-1.txt 9 words written to words-odd.txt Expected output Enter the name of the input file: 20 words read in from words-1.txt 11 words written to words-1-even.txt 9 words written to words-1-odd.txt 3: Words 1 Even 1/1 sh: 1: pause: not found Input words-1.txt Your output American computer gigantic mushroom acre screen abacus triangle math string typewriter 4: Words 1 Odda 1/1 sh: 1: pause: not found Input words-1.txt Your output River College science classes small being habitat pumpkin learn sh: 1: pause: not found Input words-2.txt Your output Enter the name of the input file: 16 words read in from words-2.txt 5 words written to words-even.txtwords-2.txt 11 words written to words-odd. txt Expected output Enter the name of the input file: 16 words read in from words-2.txt 5 words written to words-2-even.txt 11 words written to words-2-odd.txt 6: Words 2 Even ~ 0/1 Could not find file: words-2-even.txt sh: 1: pause: not found Input words-2.txt Your output Enter the name of the input file: 16 words read in from words-2.txt 5 words written to words-even.txtwords-2.txt 11 words written to words-odd. txt Expected output Montague Tybalt Mercution Benvolio Juliet Could not find file: words-2-odd.txt sh: 1: pause: not found Input words-2.txt Your output Enter the name of the input file: 16 words read in from words-2.txt 5 words written to words-even.txtwords-2.txt 11 words written to words-odd. txt Expected output Escaluse Parise Capulet Romeo Friare Balthasar Abram- Sampson Gregory Petere Nurse sh: 1: pause: not found Input words-3.txt Your output Enter the name of the input file: 17 words read in from words-3.txt 10 words written to words-even.txtwords-3.txt 7 words written to words-odd.txt Expected output Enter the name of the input file: 17 words read in from words-3.txt 10 words written to words-3-even.txt 7 words written to words-3-odd.txt 2: Words 3 Even 0/1 Could not find file: words-3-even.txt sh: 1: pause: not found Input words-3.txt Your output Enter the name of the input file: 17 words read in from words-3.txt 10 words written to words-even.txtwords-3.txt 7 words written to words-odd.txt When developing programs be- sure toe create readable Expected output source 10: Words 3 Odd A 0/1 Could not find file: words-3-odd. txt sh: 1: pause: not found Input words-3.txt Your output Enter the name of the input file: 17 words read in from words-3.txt 10 words written to words-even.txtwords-3.txt 7 words written to words-odd.txt Expected output Ie trust you enjoy programming usinge C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!