title: Function that will average out numbers that are not negative numbers
body: <p>I am supposed to allow the user to enter non-negative numbers, and once a negative number is entered, the function should display the average of the proceeding non-negative numbers. </p>
  
  <p>I am using XCode to do C++ work.</p>
  
  <pre><code>int Question6(){
      double nums;
      double totalnums = 0;
      int count = 0;
  
      cout &lt;&lt; "Please enter the numbers that you like to be average that are non-negative:";
      cin &gt;&gt; nums;
  
      while (nums &gt; 0){
          cout &lt;&lt; "Please enter the numbers that you like to be average that are non-negative:";
          cin &gt;&gt; nums;
          totalnums += nums;
          count += 1;
  
          if (nums &lt; 0){
  
              cout &lt;&lt; "You have enterd a negative number so your average is:" &lt;&lt; (totalnums/ count) &lt;&lt; endl;
  
          }
  
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I have gotten the build to be successful but it always gives me a average with the negative number included. Is there a way to stop this from happening?</p>