Pascal programming help needed please??

Associate
Joined
11 Nov 2006
Posts
549
Location
Devon
Ok i have an assigment using pascal!

The outline of the assignment is

You are to take the role of a secretary whose society requires a method of keeping their monthly/annual statistics on disc in a bespoke program format.

I have done a basic program in pascal which is below.

program TCSP;

Uses Crt;

VAR MemberFile:Text;
Count:INTEGER;
Name:String;

PROCEDURE NamesIn;
BEGIN
Rewrite (MemberFile);
FOR Count:=1 TO 20 DO
BEGIN
ClrScr;
WriteLn('Please enter member name',Count);
ReadLn(Name);
WriteLn(MemberFile,'Member',Count,'is:',name);
END;
Close(MemberFile);
ClrScr;
WriteLn('Member File Created.. press key to end.');
ReadKey;
END;
PROCEDURE ShowNames;
BEGIN
Reset(MemberFile);
WHILE NOT Eof(MemberFile)DO
BEGIN
ReadLn(MemberFile, Name);
WriteLn(Name);
END
WriteLn('Member File Listed..press key to end.');
ReadKey;
END;

BEGIN
Assign(MemberFile,'c:\FileName');
NAmesIn;
ShowNames;
end.

After entering the member name at the very beginning i want the program to ask if new details are to be entered or to look for an old member. I am unsure of how to do this and the code needed to actually look into the memberfile and locate the name.

Any help with this or some polishing up of the current program would be greatly appreciated!

Thanks in advance
 
Hi Byte thanks for your reply!

For the input spec all i need is a member name and their monthly contribution

The output spec is for total monthly contributions and possibly member names too.

Here is the flow chat of what i want to happen:


flow.jpg
 
Hi Byte thanks for your reply and your code.

I'm getting stuck on the procedure for the retrieving old member details and the procedure for the amounts to show on screen and be written to the memberfile.txt

My program functions at the moment but only displays the new members names at the end of the program. I want it to display the member names and the amounts.
 
The procedure used for writing member names to the text file is under PROCEDURE : NamesIN

Line : WriteLn(MemberFile,'Member',Count,'is:',name);

The pascal i am covering at the moment is being taught on my Access to HE course, i believe we go into more detail during the degree.
 
Back
Top Bottom