title: How do I calculate sum and average of numbers from a text.doc
body: <p>I was asked to write a program to open a txt.doc and find the: number of numbers in the list, the sum and the avg. With I compile the code my valves equal zero. I cant find out where I went wrong. </p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;cmath&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
   int main()
   {
       ifstream inputFile;
       string filename;
       int valve;
       int aNumber = 0;
       int numbers = 0;
       double sum = 0.0;
       double average = 0.0;
  
       // get file from user
       cout &lt;&lt; "enter the filename\n";
       cin &gt;&gt; filename;
       cout &lt;&lt; "_________________________________________\n";
       // open file
       inputFile.open(filename.c_str());
  
       // if loop(if the file successfully opened, process it.)
  
       if (inputFile)
       {
           while (inputFile &gt;&gt; valve)
           {
               cout &lt;&lt; valve &lt;&lt; endl;
           }
       }
       else
       {
           //display an error message
           cout &lt;&lt; "Error opening the file\n";
       }
  
       cout &lt;&lt; "\n";
  
       while (inputFile &gt;&gt; aNumber)
       {
           numbers++;
           sum += aNumber;
       }
  
       if (numbers &gt; 0)
           average = sum / numbers;
       else
           average = 0.0;
  
       cout &lt;&lt; "Number of numbers: " &lt;&lt; numbers &lt;&lt; "\n";
       cout &lt;&lt; "Sum is: " &lt;&lt; sum &lt;&lt; "\n";
       cout &lt;&lt; "Average is: " &lt;&lt; average;
  
  
       inputFile.close();
       return 0;
   }
  </code></pre>
  
  <p>I don't know why my "numbers" "sum" "average" = zero. </p>