title: How to Calculate How Many Times Inputs Entered in Sentinel Loop c++
body: <p><a href="https://i.stack.imgur.com/AVCxG.jpg" rel="nofollow noreferrer">Here</a> is the link to the programming question for detail. I have done my source code but I don't know how to calculate and display how many times inputs are entered in sentinel loop. Here is my source code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
    int i, hours;
    int tot_clients = 0;
    float charges;
    float tot_collection = 0;
    const int sentinel = -1;
  
    cout &lt;&lt; "Welcome to ABC Parking Services Sdn Bhd" &lt;&lt; endl;
    cout &lt;&lt; "=======================================" &lt;&lt; endl;
  
    while (hours != sentinel) {
      cout &lt;&lt; "Please enter number of parking hours (-1 to stop)" &lt;&lt; endl;
      cin &gt;&gt; hours;
  
      if (hours &lt;= 2 &amp;&amp; hours &gt; 0) {
        charges = 1.00 * hours;
        cout &lt;&lt; "Charges: " &lt;&lt; charges &lt;&lt; endl;
      }
      else if (hours &gt; 2 &amp;&amp; hours &lt;= 12) {
        charges = (1.00 * 2) + ((hours - 2) * 0.50);
        cout &lt;&lt; "Charges: " &lt;&lt; charges &lt;&lt; endl;
      }
      else if (hours &gt; 12) {
        charges = 10.00 * hours;
        cout &lt;&lt; "Charges: " &lt;&lt; charges &lt;&lt; endl;
      }
      else if (hours == sentinel) {
        break;
      }
  
      tot_collection = tot_collection + charges;
    }
  
    cout &lt;&lt; "SUMMARY OF REPORT" &lt;&lt; endl;
    cout &lt;&lt; "=======================================" &lt;&lt; endl;
  
    cout &lt;&lt; "Total clients:" &lt;&lt; tot_clients &lt;&lt; endl;
    cout &lt;&lt; "Total colletion:" &lt;&lt; tot_collection &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>
  
  <p>Hope someone can help me solving this. I am studying for my programming final exam.</p>