|
-
Mar 24th, 2009, 09:32 PM
#1
Thread Starter
New Member
Help with program
Howdy
Alright could really use help on getting this program working correctly.
What I want it to do is to read my text file,
Smith, John
532
589
Jones, Dan
421
610
and then I want it to rearrange the names and scores and write to the outfile
Name_____________Math Score_________English Score________Total Score
Dan Jones _________421_______________610__________________1041
John Smith _________532_______________589__________________1121
I just can't seem to get any of this right, if anyone could help I would greatly appreciate it 
Code:
program SatScores;
uses
Forms;
{ }
Const
DATA_NUMB = 2;
type
info=record
name,fName,lName:string;
newName:string;
end;
studArray=array[1..DATA_NUMB]of info;
var
data:studArray;
outFile,inFile:textFile;
number:integer;
N:string;
Procedure Start;
begin
Assignfile(outfile,'Info.out');
rewrite(outfile);
Assignfile(infile,'Data.txt');
reset(infile);
write('What is your name?: ');
readln(N);
writeln(outfile,'This program was run by: ',N);
writeln(outfile);
end;
Procedure GetInfo;
var
loop:integer;
begin
for loop:=1 to DATA_NUMB do
begin
readln(infile,data[loop].name);
end;
end;
Procedure Calculate;
begin
readln(infile,number);
writeln(outfile,number);
writeln(outfile,'----------------------------------------');
end;
Procedure Date;
Var
blnkSpace,ndspace,comma:integer;
loop:integer;
name,fName,lName:string;
newDate,newName:string;
begin
blnkspace:=pos(' ',data[loop].name);
comma:=pos(',',data[loop].name);
fName:=copy(data[loop].name,succ(blnkspace),length(data[loop].name)-blnkspace);
lName:=copy(data[loop].name,1,pred(blnkspace));
newName:=Concat(fName,lName);
writeln(outfile,'----------------------------------------');
writeln(outfile,'Old name:',data[loop].name);
writeln(outfile,'New name:',newName);
end;
Procedure Finish;
begin
writeln(outfile);
writeln(outfile,'This program was created by ');
closefile(outfile);
closefile(infile);
end;
begin
Start;
GetInfo;
Calculate;
Finish;
end.
This is the text file
Code:
Smith, John
532
589
Jones, Dan
421
610
Dover, Ilene
338
499
Adams, Paige
670
200
Last edited by la65cop; Mar 24th, 2009 at 09:39 PM.
-
Apr 1st, 2009, 11:42 PM
#2
Re: Help with program
Perhaps posting what language this is might help?
-
Apr 9th, 2009, 01:07 AM
#3
New Member
Re: Help with program
That's a Pascal command line program. It was posted over a month ago so I won't debug it, but there are easier ways of doing that in Delphi or FreePascal with Lazarus. Well, unless it's a classroom project or something that requires using the old school ways...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|