Problem solving and debugging.
Linux redirection to read data from a file.
Use of conditional loop (while).
Data File Description
A data file for this exercise will consist of several lines of text that form sentences. The text may include letters, punctuation marks, and/or digits. Each sentence will be terminated with either a period (.), an exclamation mark (!), or a question mark (?).
Design and implement a complete C++ program that will
using Linux redirection, read the contents of the file and
compute the average number of letters per sentence in the file
count the number of digits in the file
display the average with a label and 3 digits to the right of the decimal
display the digit count with a label
NOTES:
Make sure you choose enough test data to ensure that your program meets all the requirements.
If you use any library functions in your program make sure you include the appropriate header file(s).
Sample terminal session:
[keys]$ more data4eight
What is Earth Day? Earth Day is
celebrated annually on April 22 to demonstrate support for
environmental protection. It was first marked
in 1970 and is coordinated globally by the
Earth Day Network. More than
193 countries participate each year.
[keys]$ g++ ex08.cpp
[keys]$ ./a.out < data4eight
Average # of letters per sentence is 48.250
Total # of digits in the file is 9
**EXTRA NOTES:
-This does NOT use fstream. Input will be taken through cin.
-String cannot be used. The program can be created without it.
-USE A WHILE LOOP.
-Do not use functions, arrays, or strings.
Part of my program:
#include
#include
using namespace std;
int main()
{
cin >> data;
while (cin)
{
cin >> data;
}
return 0;
}