Question: 4.3.5: Advanced while loop examples. Use cin to read strings from input until Finale is read. Count the number of times the first string is

4.3.5: Advanced while loop examples.

Use cin to read strings from input until "Finale" is read. Count the number of times the first string is read from input, including the first instance.

Ex: If the input is:

Yam Cucumber Fig Leek Yam Finale

then the output is:

Yam occurs 2 time(s).

Note: x == y returns true if string x is equal to string y.

#include #include using namespace std;

int main() { string expectedItem; string nextItem; int yamCount;

cout << expectedItem << " occurs " << yamCount << " time(s)." << endl;

return 0; }

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!