// Loopwrit.cpp -- omitted by Knowlton; written by DFS
#include<fstream.h>  // necessary for file I/O
#include<iostream.h>
#include<iomanip.h>

int main()
{
 float x;
 ofstream outfile;    // declares file pointer named outfile

 outfile.open("FLOATS.DAT",ios::out);  // open file for output

 if (outfile)
  {
    cout << "Enter a series of floating-point numbers.\n";
    cout << "Enter a zero to end the series.\n";
    outfile << setprecision(1); // set display to one decimal point
    outfile.setf(ios::fixed);  // prevent numbers from appearing in E-notation

    cin >> x;        // get number from user
    do  // repeat the loop until 0.0 is encountered
     {
       outfile << x << endl;  // print number to the file
       cin >> x;        // get number from user
     } while(x != 0.0);
  }
 else          // If error occurred, display message.
  {
   cout << "An error occurred while opening the file.\n";
  }
 outfile.close();  // close the output file
 return 0;
}

