So you need two changes. Firstly, somewhere you want to change the value of 'J' .
Secondly, you need to put your cout<< statement somewhere that it only prints once.
Have a look at the structure of the program, based on what you know about your output..
Code://Everything up here is executed once
while (position != string::npos)
{
//Everything between these curly braces is executed per each occurrance of "John"
position = quote.find("John", position +1);
cout << "The number of times John was used is: " << j;
}
//Everything down here is executed once

