// focus on the input stage, by implementing all methods for validating and verifying the data. (1st ammend) //seed division algorithm 31/3//[completed]9/4 //school seperation algo 31/3//originalporgram lost10/4//[mod needed]10/4//notes:position not constant //one school distribution tendency 31/3// " //improve validation,verification//[in process]10/4//booleanvalidation added10/4 program ictsba_mki; type stud=record school: string; studname: string; //seed: boolean;)(cant read in bollean?) seed: string;//require check if input is t/f/true/false end; var i,j,k,l,m,n,o,p,q,r,schoolcount:integer; studfile:text;//var for file studfileinput:char;//var for receiving file name temp:stud; studinfo:array[1..1000]of stud; schooltemp:array[1..1000]of character; procedure reading; begin write('input file name');//change to read in data later readln(studfileinput); assign(studfile,studfileinput);//input desired file name reset(studfile); while not eof(studfile) do begin i:=i+1; readln(studfile,studinfo[i].school); readln(studfile,studinfo[i].studname); readln(studfile,studinfo[i].seed); end; close (studfile); readln(); end; procedure sorting;//change to merge sort later//later10/4//is this useful? begin for j:= 1 to i-1 do begin for k:= 1 to n-1 do begin if studinfo[j]>studinfo[j+1]then begin temp:=studinfo[k]; studinfo[k]:=studinfo[k+1]; studinfo[k+1]:=studinfo[k]; end; end; end; readln() end; procedure namevalidationblank;//showing position and name of blank names of students// begin for s:= 1 to i do begin if studinfo[s].studname = '' begin writeln(s); end; end; if s>0 then begin writeln('invalid input(blank data in the following lines),please amend file for the following data:'); end; readln() end; procedure namevalidationrepeat;//showing position and name of duplicating names of students//possibility of repeating names?//tell them add num after name to avoid confusion in all process begin for l:= 2 to i do begin if studinfo[l-1].studname <> studinfo[l].studname then begin studinfo[l-1].studname:= ' '; else; begin m:=m+1; writeln(studinfo[l].studname,'input'l); end; end; end; if m>0 then begin writeln('invalid input(repeating names,in case of non-accidental case,please amend by addind numbers to avoid confusion),please amend file for the following data:'); end; readln() end; procedure schoolnamevalidation;//o:counter,p:invalid counter//concept error begin for o:= 2 to i do begin if studinfo[o-1].school <> studinfo[o].school then begin studinfo[o-1].school:= ' ' end; else; begin p:=p+1; writeln(studinfo[o].school,'input'o); end; end; if p>0 then begin writeln('invalid input,please amend file for the following data:'); end; readln() end; procedure schoollimit;//assume n as total data begin for a = 1 to n do begin for b = a+1 to n-1 do begin if studinfo[a].school = studinfo[b-1],school then begin write(studinfo[a].school); end; end; writeln('the schools shown are having more than 2 competitors, please do neccesary adjustment') end; procedure seedvalidation;//p:counter,q:invalid counter begin for p:= 1 to i do begin if studinfo[p].seed = true then begin q:=q+1; end; end; if q>4 then begin writeln('invalid input,please amend file for the following data:'); end; readln() end; procedure booleanvalidation;//assume that the text file followed a format of standard for boolean input eg.true/false as of in seed validation//do before seed validation//r:counter begin for r:= 1 to i do begin if studinfo[r].seed <> true or false begin writeln ('invalid input for student'r'please follow the following format: true, false'); end; end; end; begin i,j,k,l,m,n,o:=0; repeat reading; sorting; namevalidation; schoolnamevalidation; booleanvalidation; seedvalidation; until m=0 and p=0 and q<4 or q>=0; readln() end. //other mock programmes will be added after succesful unit test(lower is the program for seed division[mock]) program sd_algo_mki;//testing only,not official program,assume graph as paper mockup, n as total data var seed,a,b,c:integer; begin for a := 1 to n do begin if studinfo.seed[a] = true then//count seed begin seed := seed +1; end; end; while b <> seed and c <>n do begin c:=c+1; if studinfo[c].seed = true and b:=0 then//first seed begin mockgraph[n] := studinfo[c]; b:=b+1; end; if studinfo[c].seed = true and b:=1 then//second seed begin mockgraph[1] := studinfo[c]; b:=b+1; end; if studinfo[c].seed = true and b:=2 then//third seed begin mockgraph[n/2] := studinfo[c]; b:=b+1; temp:=c; end; if studinfo[c].seed = true and b:=3 then//forth seed begin mockgraph[(2+n)/2] := studinfo[temp]; mockgraph[3n/2] := studinfo[c]; b:=b+1; end; end; readln() end. //mockgraph as mock array for storing data of tree//setted location proved to be effective on dryrun, assume position of the program as correct
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more