Question: Hi, this is the 3rd time that i am posting this question and asking for help and receiving an incorrect answer. Please if you are

Hi, this is the 3rd time that i am posting this question and asking for help and receiving an incorrect answer. Please if you are not fully getting the question don't answer it. I have an incomplete code for this question which i am posting it along with the question. The problem with the code is that it over writes the total words in file and the numbers of even and odd words are different to what system wants and some new line issues. please note that the code must print the file name that users enter with addition of -even or -odd. for example, if the user gives file name the program should print 1- total # number read from word-1.txt. 2- #word written to word-1-even.txt. 3- #words written to word-1-odd.text. i am attaching the screenshots of all conditions that the system checks the code as well as the question and my incomplete code. Thank you

Note: the file names are visible which the system checks the code with.

Hi, this is the 3rd time that i am posting this questionand asking for help and receiving an incorrect answer. Please if youare not fully getting the question don't answer it. I have anincomplete code for this question which i am posting it along withthe question. The problem with the code is that it over writesthe total words in file and the numbers of even and oddwords are different to what system wants and some new line issues.please note that the code must print the file name that usersenter with addition of -even or -odd. for example, if the usergives file name the program should print 1- total # number read

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 Compiler warnings main.cpp: In function 'int main()': main.cpp:14:17: warning: comparison of integer expressions of different signedness: 'int' 14 1 if (pos != filename.length() - 4) an main.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' an 16 | } while (pos != filename.length() - 4); 1 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 Output differs. See highlights below. Input words-1.txt Your output Enter the name of the input file: 21 words read in from words-1.txt 12 words written to words-1-even.txt 9 words written to words-1-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 Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input words-1.txt American computer gigantic mushroom acre Your output screen abacus triangle math string typewriter Expected output American computer gigantic mushroom acre screen abacus triangle math string typewriter 4: Words 1 Odda Input words-1.txt Your output River College science classes small being habitat pumpkin learn 5: Words 2 Summary ^ Output differs. See highlights below. Input words-2.txt Your output Enter the name of the input file: 17 words read in from words-2.txt 6 words written to words-2-even.txt 11 words written to words-2-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 Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input words-2.txt Montague Tybalt Mercutio Benvolio Juliet Your output Expected output Montague Tybalt Mercutio Benvolio Juliet 7: Words 2 Odda Input words-2.txt Escalus Paris Capulet Romeo Friar Balthasar Abram Sampson Gregory Peter Your output Nurse 8: Words 3 Summary ^ Output differs. See highlights below. Input words-3.txt Your output Enter the name of the input file: 18 words read in from words-3.txt 11 words written to words-3-even.txt 7 words written to words-3-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 9: Words 3 Even Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input words-3.txt When developing programs be sure Your output to create readable source code Expected output When developing programs be sure to create readable source code 10: Words 3 Odda 1/1 Input words-3.txt Your output I trust you enjoy programming using C++ 8 9 0 1 5 6 1 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { string filename; int pos; do { cout > filename; 3 pos = filename.find(".txt"); 4 if (pos != filename.length() - 4) cout > word; if (word.length() % 2 == 0) { ofse

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!