Question: CSCI 201 - Computer Science 1 Homework Assignment 4 A program that counts frequencies of characters. Due on Wednesday Feb 8 Objectives. The objectives of

CSCI 201 - Computer Science 1 Homework Assignment 4 A program that counts frequencies of characters. Due on Wednesday Feb 8 Objectives. The objectives of this assignment are: 1. Learn how to process a teat file using a ub1le loop C++. 2. Process multiple files by nesting a while inside a for loop. In this asignment, you will create a program that counts the frequencies of some characters and priats she result to an outpet file. For the current usage trends in Bneliah, the characters E, T, A, O, I, N, S, H and R are the most common ones. Your program will count the nocurrences of each of these characters is the input file, and output the number of oceurrences of each character, and also the total number of characters. The program should handle multiple files in a single execution. The program fint prompts for the number of files to be procesed and the name of the file where the results should be writter; for each file it prompts for the name of the file, and prints the results to the spocified output file. As an example, a sample run should bok something like this: Welconel Hou many files are you processing: 2 . Please input the natre of the output flle: Counts. txt Please input the nase of the 12le: FiratFile.txt FiratFile.txt has been processed. Please ingut the natre of the file: AnotherFile.txt AnotherFile, txt has been processed. Tank-you, Goodbyel. The output file (Counts, txt) should eed up looking sotnething like this: File nase: FiratFile.txt Nharber of E'st 19 Nunber of T's: 15 Nunber of A :s: 19 Wubber of 0 's: 9 Humber of I's: 2 Number of N s: 7 Sumber of s'st 11 Nunber of H'st 4 Namber of N's: 10 Total Nubber of charactere: 237 File bare: AnotberFile.txt. Number of E 's: 16 Suaber of T's: 11 Nunber of AE:13 Number of 0=9 Number of I1 s: 2 Number of N2s:13 Number of S:11 Number of. Hs:5 Number of R3 : 11 Total Number of characterst 197 Some important points to keep in mind: 1. Create data files in emacs or notepad ++ (not gedit). There should be no blank lines at the end, i.e., no carriage returns after the last character. 2. Clear the input file stream variable after cach file. This is done by inserting the statement infile, clear () immediately after infile. close (). This is needed because the same file stream is being tured for all the input fles. 3. Choosing appropriate kinds of control structures. Use a for loop that executes as many times as the number of files to be processed and an inner while loop that processes each file. Chocse an approptiate branching construct; we want the code to look clean and casy to read. 4. Cotnting both upper and lower case. Remember to include both the upper and lower case letters when you count. 5. Testing. Tests should use text flles that come from 2 or 3 different souroes, and should include some for which the counts are independently verified. Report these results in a table. 6. Dealing avith bad input file names. If the user enters a file name that does not exist, the program should not exit (via return 0). but simply move on to the next file, Co., skip over the rest of the for loop for that iteration. What to turn in. The following ltems must be uploaded to a folder named hwork4 within your CourseFles folder. - A script file (showing the source file, compilation and the test runs). Display the inpat files befote each execution and the generated output file after cach execution. - A tahlo moroing the test results. - A user manual. A good roer manual should coutain the following information in abi. itemitiod format and a friendly layud. 1. The purpose of the program. 2. Whery to find the program asd how to run it: 3. What the input should took like and what kind of outprat to expect. Ese examphs ast niecedet. 4. Any blocial oubalitions ind ciwrata. these the mast appropitiate in rach cose? Fexplaits. How did you deal with leat inpuat file namps
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
