Question
For this programming project you are to write a C++ program which calculates the statistics described below for a user-specified text file. This assignment has
For this programming project you are to write a C++ program which calculates the statistics described below for a user-specified text file. This assignment has some requirements about how your program should work.
Statistics from the text
- word count -- how many words are in the text
- total word length -- the total number of characters in all words in the text
- minimum and maximum lengths -- the shortest and longest words in the text
- average word length -- calculated from the total length and the number of words
For our purposes a word is a non-empty string that has no leading and trailing punctuation characters. You find the words in a file by extracting each token and removing any leading or trailing punctuation characters. If what remains is not empty then that result is a word. We have used the function ispunct() in a lab.
How your program should work
(These are requirements)
Your program should ask the user for the filename to be processed. Do this in main(). After acquiring the filename from the user main() should call a function named processFile() to process the file. If the file exists processFile() should calculate the statistics for the text and return those values back to main() where they should be displayed. If the file does not exist, the function should terminate the program with an appropriate message. We will review how to terminate a program on Monday (Jan 27).
Examples below show the format for the output and demonstrate the program's behavior. Your program should match the examples. Your program should also work correctly on files not given in the examples
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started