Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

ISBN: 303139688X, 978-3031396885

More Books

Students also viewed these Databases questions

Question

(0.073cm30.041cm3)(2103g+6.785g)=[8cm3g

Answered: 1 week ago

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago