Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C + + program that reads lines from a file until the end of file. The program should prompt the user for the

Write a C++ program that reads lines from a file until the end of file. The program should prompt the user for the file name to read from. The program should open the fite for reading, and if the file eannot be opened, it should print the message "File cannot be opened ", followed by the filename, and exit.
The program acts like a simple interpreter for a scripting/command language. The file includes commented lines that are recognized by either the character 'H', as the start character of the line: or by "W", as the first two characters of the line. The program should skip over all commented lines. For the rest of the file, the program should keep track of the total number of lines read, the number of non-commented lines, the line of the maximum length, the number of words, and the word of maximum length.
A word is defined as a sequence of one or more non-whitespace characters. Note that a line having only whitespace characters is referred to as a blank line. After reading the contents of the input file, the program should print out the total number of lines, the number of non-commented lines, the line of the maximum length delimited by double quotes, the number of words, and the word of maximum length delimited by double quotes, as shown in the following example.
image text in transcribed

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago