/* failuretime11.cpp uses a query-controlled loop to process a
 * collection of failure times and find the mean time to failure.
 *
 *  Input:   a collection of component failure times and
 *           user's response to "more data?" query
 *  Output:  prompts and the average of the failure times.
 ****************************************************************/

#include <iostream.h>                // <<, >>, cout, cin

int main()
{
   cout << "Computing Component Mean Time to Failure\n";

   int numComponents = 0;
   double failureTime,
          failureTimeSum = 0.0;
   char response;

   do
   {
      cout << "\nEnter a failure time: ";
      cin >> failureTime;

      failureTimeSum += failureTime;
      numComponents++;

      cout << "Do you have more data to enter (y or n)? ";
      cin >> response;
   } while (response == 'y' || response == 'Y');

   cout << "\nThe mean failure time of the " 
        << numComponents << " components is " 
        << failureTimeSum / numComponents << endl;

   return 0;
}


