Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5.3 - Using Files -Word processing - 8 points Based on a problem from Nell Dale, Chip Weems and Mark Headington, Programming and Problem Solving

image text in transcribed
image text in transcribed
5.3 - Using Files -Word processing - 8 points Based on a problem from Nell Dale, Chip Weems and Mark Headington, Programming and Problem Solving with C++ Write a program that prints out the fle data and number of words in a file of text. We will define a word to be any sequence of non-whitespace characters. So "hi&there..mom" would be considered a single word. Solve this file data processing programming challenge using appropriate nested looping constructs such as (1) loop to allow for multiple file reads (2) loops to read file data as strings and/or character-by-character (3) loops for file validation routines You may consider a loop that uses a string variable to terate through each word read from the file and thus keep a word count. Another char variable can be used in a seperate loop to display the file data content using a character-by character fle data read loop iteration. Your program should ask the user for the name of the fle to display file content nd a word count (for runtime input of filenames see Chapter #5 section 5.12 in the Gaddis text titled "Letting the User Specify a Filename" on pgs 300-301). The program should loop until the user types "quit" for the name of the file. Here m the file and thus keep a word some hints for assignment 5.3 Upload your final completed version of source code and make sure that you have run several compile/ test runs entering these 5 data files: file 1.file 2.file 3.fle 4, file 5 Using notepad or textedit, I suggest that you copy/paste the text from each of these five web pages to create five separate text files. Important note: Save these files in the same folder in which you have your working copy of your source code Xcode users on the MAC platform have had particular difficulty when working with data files, so please post your solution to this issue in the class discussion area titled Q&A ...a.bout compilers. This will be helpful to other XCoder's...Thanks! File and Data validation: Appropriate validation methods should be used to ensure that the file stream is not in fail state In other words you will need to include validation routines to check the following (1) whether the data file opened successfully and (2) the data read from the file matches the variable (datatype) into which the value will be stored Failure to do so will mean that your program may run but will not produce correct output. Here are some source code hints that you may find helpful in implementing the validation routines. ere us a sample test run of the file processing program using two of the sample data files given above. FILE PROCESSING PROSRAM Enter a filenase oz type quit to exit: filel.txt filel.txt data This 4%til should

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions