# PASCAL DATA FILES

[b][red]This message was edited by Kuin at 2006-11-29 18:55:41[/red][/b][hr]
im having some trouble with this program lately. Im kind of new to this whole thing so im not sure. here's what my program's suppose to be. my data file is called INCOME, containing the salaries for every employee in the company. each salary amt. is preceded by F for female and M for male. if the employeee is neither sex output an appropriate and insightful error msg. compute the average salaries for male and females and provide insightful information in the output. how would i get my program to work this way?

## Comments

• : [b][red]This message was edited by Kuin at 2006-11-29 18:55:41[/red][/b][hr]
: im having some trouble with this program lately. Im kind of new to this whole thing so im not sure. here's what my program's suppose to be. my data file is called INCOME, containing the salaries for every employee in the company. each salary amt. is preceded by F for female and M for male. if the employeee is neither sex output an appropriate and insightful error msg. compute the average salaries for male and females and provide insightful information in the output. how would i get my program to work this way?
:
:
:
For this you need 2 arrays, one for the female salaries and one for the male. Then the program looks something like this:
[code]
var
sex: char;
begin
Open file for reading
while not eof(file) do
begin
read salary and sex
case sex of
'M': add salary to male salaries array
'F': add salary to female salaries array
else writeln('some insightful error message');
end;
end;
Close file;
Average values stored in male salaries array
Average values stored in female salaries array
writeln('Insightful info: ', male average);
writeln('Insightful info: ', female average);
end;
[/code]
• [b][red]This message was edited by Kuin at 2006-11-30 18:31:29[/red][/b][hr]
: : [b][red]This message was edited by Kuin at 2006-11-29 18:55:41[/red][/b][hr]
: : im having some trouble with this program lately. Im kind of new to this whole thing so im not sure. here's what my program's suppose to be. my data file is called INCOME, containing the salaries for every employee in the company. each salary amt. is preceded by F for female and M for male. if the employeee is neither sex output an appropriate and insightful error msg. compute the average salaries for male and females and provide insightful information in the output. how would i get my program to work this way?
: :
: :
: :
: For this you need 2 arrays, one for the female salaries and one for the male. Then the program looks something like this:
: [code]
: var
: sex: char;
: begin
: Open file for reading
: while not eof(file) do
: begin
: read salary and sex
: case sex of
: 'M': add salary to male salaries array
: 'F': add salary to female salaries array
: else writeln('some insightful error message');
: end;
: end;
: Close file;
: Average values stored in male salaries array
: Average values stored in female salaries array
: writeln('Insightful info: ', male average);
: writeln('Insightful info: ', female average);
: end;
: [/code]
:

Thanks a lot for the help.

Sign In or Register to comment.

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!