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
This is the text fileCode: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.
Code:Smith, John 532 589 Jones, Dan 421 610 Dover, Ilene 338 499 Adams, Paige 670 200





Reply With Quote