Link to home
Start Free TrialLog in
Avatar of kazooie21
kazooie21

asked on

create two separate files and print

Each data group for the file customer.dat contains a customer's name, address, gender, and balance due. I need a program that will create two separate files, male.dat and female.dat, with all the data for customers stored on the appropiate file. It will also have to print out the following:
total number of customers, number of males, number of females, average balance for males, and average balance for females.

Can I use the code in my other question? https://www.experts-exchange.com/jsp/qShow.jsp?ta=pascal&qid=10302610 
Avatar of dbrunton
dbrunton
Flag of New Zealand image

Yes.

The basics are there.  Roughly

females := 0;
males := 0;
malebalance := 0;
femalebalance := 0;

while not eof(customerfile)
  readln(customerfile, name);
  readln(customerfile, address);
  readln(customerfile, gender);
  readln(customerfile, balance);
  if gender = 'M' then
    begin
      write(malefile, name);
      write(malefile, address);
 etc
      malebalance := malebalance + balance;
      inc(males);
    end
  else
    begin
      write(femalefile, name);
etc
      femalebalance := femalebalance + balance
      inc(females);
    end;


you should be able to finish this off by calculating total number of customers and mean average balances.
ASKER CERTIFIED SOLUTION
Avatar of sumant032199
sumant032199
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial