/* lists9.cpp processes two lists, summing the values in one,
 * and finding the product of the values in the other.
 *
 * Input:   two sequences of numbers
 * Output:  the sum of the numbers in the first sequence,
 *          the product of the numbers in the second sequence.
 ***************************************************************/

#include <iostream.h>          // <<, cout, cin, get, eof(), clear()

int main()
{
   cout << "This program reads two lists, summing the first\n"
           "and finding the product of the numbers in the second.\n\n"
           "Enter the list to be summed (end list with eof):\n";

	double number,
          sum = 0;

   for (;;)                                       // read 1st list
   {
      cin >> number;
      if (cin.eof()) break;
      sum += number;
   }
                                                  // eof flag is set,
   cin.clear();                                   //  so clear it
   char EOF_char;
   cin.get(EOF_char);                             //  and remove EOF mark
   
   cout << "\nEnter the list to be multiplied (end list with eof):\n";

   double product = 1;

   for (;;)                                       // read 2cd list
   {
      cin >> number;
      if (cin.eof()) break;
      product *= number;
   }

   cout << "\nThe sum of the first list is " << sum << endl
        << "and the product of the second list is " << product << endl;

   return 0;
}


