Question: C++ Programming void countWords(ifstream& in, ostream& out) { } Write a function named tokenstats that accepts an input stream and an output stream as parameters.

C++ Programming

void countWords(ifstream& in, ostream& out) {

}

C++ Programming void countWords(ifstream& in, ostream& out) { } Write a function

Write a function named tokenstats that accepts an input stream and an output stream as parameters. The input stream represents an input file containing a series of tokens. It should print out the sum of all the tokens that are legal integers, the sum of all the tokens that are legal real numbers but not integers, and the total number of tokens of any kind. For example, if an input stream called data contains the following tokens 3 3.14 10 squid 10.x 6.0 Then the call of tokenStats (data, cout); should print the following output: integers: 13 real numbers: 9.14 total tokens: 6 If the input stream has no tokens, the function should print integers: 0 real numbers: 0.0 total tokens

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!