//Rob Gross
//assignment3
//5/4/02

#include<iostream>
#include<iomanip.h>
#include<fstream.h>
#include <process.h>

void main()
{
    char Name[100];
    float Owes;
	float Acct_num;
    fstream customers;

    customers.open("customers.txt", ios::out);
    if (!customers)
    {
	cout << "Cannot open file - customers.txt";
	exit(1);
    }
	cout << "Enter your Name Please: ";
	cin >> Name;
    while (Name[0] != '\0' )
	{
		cout << "Enter your account number: ";
		cin  >> Acct_num;
		
		cout << "Enter amount owed: ";
	    cin >> Owes;
	    customers << Name << Acct_num << " " << Owes << endl;
		
		cout << "Enter customer's name (blank to exit): ";
		cin.ignore();
		cin.getline(Name,100,'\n');
	}

	customers.close();
	customers.open("customers.txt", ios::in);

    //customers.seekg(0,ios::beg);
	customers.seekg(0);

	cout << "\n\nThis is the text in the file\n";
    customers >> Name;
	cout << "Name" <<  "   " << "Acct_num" <<  "   "  << "Owes" <<  "   " << endl;
    while ( !customers.eof() )
    {
	    customers >> Owes;
        customers.ignore(); //ignore the LF character
		cout << Name << "   " << Acct_num << "   " << Owes << "   " << endl;
	    customers >> Name;
    }
    customers.close();
}