Search
 
 

Display results as :
 


Rechercher Advanced Search

Keywords

Latest topics
» A Pascal Program to Marks the scores of students in three courses!
Tue Feb 12, 2013 7:07 am by Morris

» Download Force3.0 for fortran
Mon Dec 17, 2012 10:41 am by Morris

» A simple Pascal program to turn on/off an AC
Mon Dec 17, 2012 10:23 am by Morris

» Download IDE/Compiler for Pascal
Sat Dec 01, 2012 1:00 am by Morris

» Here is a a FORTRAN COMPILER FOR FREE DOWNLOAD!
Tue Nov 27, 2012 6:56 am by Morris

» ALERT! A NEW TROZAN THAT STEALS YOUR PICTURES
Mon Nov 26, 2012 11:59 am by Morris

» Dell cellular broadband modem.
Sun Sep 23, 2012 6:35 am by Alphamj

» 2011/2012 SPDC Joint Venture University Scholarship Award Scheme
Thu Jul 26, 2012 8:46 pm by Morris

» A mad man and a foolish thief.
Wed Jul 25, 2012 6:33 pm by Alphamj

July 2017
MonTueWedThuFriSatSun
     12
3456789
10111213141516
17181920212223
24252627282930
31      

Calendar Calendar


A Pascal Program to Marks the scores of students in three courses!

View previous topic View next topic Go down

A Pascal Program to Marks the scores of students in three courses!

Post by Morris on Tue Feb 12, 2013 7:07 am

Note: to run the following program you need the following text files saved in the same directory as your program code.
mathans //this holds the examiners answer to math,should be arrange on one line,no space.
genans //this holds the examiners answer to Gen. Paper,should be arrange on one line,no space.
engans //this holds the examiners answer to english,should be arrange on one line,no space.
studentreceng //this holds students answers to english as well as their exam no. & name.
studentrecmath //this holds students answers to math as well as their exam no. & name.
studentecgen //this holds students answers to Gen.Paper as well as their exam no. & name.
studentscore // holds the output of student result....

here is the sample of file mathans.txt
ADBBE // this means five option

here is the sample of file studentrecmath
PSC1102453
JOY FELIX
ABADB
PSC1102208
Hanna Miracle
ACCDE
PSC1103786
BLESSING Okon
ACDEE

Take Note: this program marks result for 5 student,for 5 questions in three courses namely english,math,Gen.Paper..you can edit your code take as much student as possible....
Code:

program minetest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

var
  studnum,i,j,k: integer;
  score: integer;
  tempid: integer;
  temptotal: integer;
  ID: array[1..5] of integer;
  dummytotal: array[1..5] of integer;
  answer,mathans: array[1..5] of char;
  engans: array[1..5] of char;
  genans: array[1..5] of char;
  engfile: text;
    mathfile: text;
    genfile: text;
    choicemath: text;
    choiceeng: text;
    choicegen: text;
    studentscorefile: text;
    exammath,exameng,examgen: array[1..10] of char;

  studentrec: record
    Examno: array[1..5] of string;
    name: array[1..5] of string;
    mathscore: array[1..5] of integer;
    engscore: array[1..5] of integer;
    genscore: array[1..5] of integer;
    totalscore :array[1..5] of integer;
    percentageaverage: array[1..5] of real;
  end;
  Function markmaths(a:integer):integer;
begin
  //reading Examiner's Maths answers
  AssignFile(mathfile,'mathans.txt');
  Reset(mathfile);
  while not EOF(mathfile) do
  begin
    for i:= 1 to 5 do
    begin
    Read(mathfile,exammath[i]);
    end;
  end;
    Close(mathfile);
  score:=0;
  //reading student maths answers
  AssignFile(choicemath,'studentrecmath.txt');
    Reset(choicemath);

    while not EOF(choicemath) do
  begin
  for k:=1 to 5 do
    begin
    score:=0;
  readln(choicemath,studentrec.Examno[k]);
  readln(choicemath,studentrec.name[k]);
  readln(choicemath,answer[1],answer[2],answer[3],answer[4],answer[5]);

  for i:= 1 to 5 do
  begin
    if (exammath[i]=answer[i]) then
  begin
      score := score + 1
  end
  else
  begin
  score := score + 0;
  end;
  end;
  studentrec.mathscore[k]:=score;
  end;
    end;
    Close(choicemath);
  Result:=score;
end;

Function markeng(a:integer):integer;
begin
  //reading Examiner's english answers
  AssignFile(engfile,'engans.txt');
  Reset(engfile);
    while not EOF(engfile) do
  begin
    for i:= 1 to 5 do
    begin
    Read(engfile,exameng[i]);
    end;
  end;
    Close(engfile);
  score:=0;
  //reading student english answers
  AssignFile(choiceeng,'studentreceng.txt');
    Reset(choiceeng);
    while not EOF(choiceeng) do
  begin
  for k:=1 to 5 do
    begin
    score:=0;
  readln(choiceeng,studentrec.Examno[k]);
  readln(choiceeng,studentrec.name[k]);
  readln(choiceeng,answer[1],answer[2],answer[3],answer[4],answer[5]);

  for i:= 1 to 5 do
  begin
    if (exameng[i]=answer[i]) then
  begin
      score := score + 1
  end
  else
  begin
  score := score + 0;
  end;
  end;
  studentrec.engscore[k]:=score;
  end;
    end;
    Close(choiceeng);
  Result:=score;
 end;
function markgen(a:integer):integer;
begin
  //reading Examiner's general paper answers
    AssignFile(genfile,'genans.txt');
  Reset(genfile);
    while not EOF(genfile) do
  begin
    for i:= 1 to 5 do
    begin
    Read(genfile,examgen[i]);
    end;
  end;
    Close(genfile);
    score:=0;
    //reading student general paper answer
 AssignFile(choicegen,'studentrecgen.txt');
    Reset(choicegen);
    while not EOF(choicegen) do
  begin
  for k:=1 to 5 do
    begin
    score:=0;
  readln(choicegen,studentrec.Examno[k]);
  readln(choicegen,studentrec.name[k]);
  readln(choicegen,answer[1],answer[2],answer[3],answer[4],answer[5]);

  for i:= 1 to 5 do
  begin
    if (examgen[i]=answer[i]) then
  begin
      score := score + 1
  end
  else
  begin
  score := score + 0;
  end;
  end;
  studentrec.genscore[k]:=score;
  end;
    end;
    Close(choicegen);
  Result:=score;
 end;

begin
AssignFile(studentscorefile,'studentscore.txt');
  Rewrite(studentscorefile);

writeln('******** WELCOME TO STUDENT MARKING PROGRAM **********');
writeln('');
writeln('Order of marking is Maths, English & lastly General paper');
writeln('');


  writeln('last student score for maths is ',markmaths(studnum));
  writeln('last student score for english is ',markeng(studnum));
  writeln('last student score for general paper is ',markgen(studnum));

  for i:= 1 to 5 do
  begin
      studentrec.totalscore[i]:= studentrec.mathscore[i] +
  studentrec.engscore[i] + studentrec.genscore[i];
    dummytotal[i]:= studentrec.mathscore[i] + studentrec.engscore[i] + studentrec.genscore[i];
  studentrec.percentageaverage[i]:=(studentrec.totalscore[i]/15)*100;
  ID[i]:= i;
  end;

//start bubble sorting
    for j:=1 to 4 do
    begin
    for k:= j+1 to 5 do
    begin
        if(dummytotal[j]<dummytotal[k]) then
        begin
        temptotal:=dummytotal[j];
        tempid:=ID[j];
        dummytotal[j]:=dummytotal[k];
        ID[j]:=ID[k];
        dummytotal[k]:=temptotal;
        ID[k]:=tempid;
        end;

    end;
    end;

 writeln('******* ARRANGING IN DESCENDING ORDER ********');
 writeln('EXAM NO.      NAME        MATH  ENGLISH GEN.PAPER  TOTAL  PERCENTAGE AVG. ');
 writeln('');

 //outing result to student score file
 writeln(studentscorefile,'******* ARRANGING IN DESCENDING ORDER ********');
 writeln(studentscorefile,'EXAM NO.      NAME        MATH  ENGLISH GEN.PAPER  TOTAL  PERCENTAGE AVG. ');
 writeln(studentscorefile,' ');
 for i:=1 to 5 do
 begin
  writeln(studentscorefile,studentrec.Examno[ID[i]],' ',studentrec.name[ID[i]],' ',studentrec.mathscore[ID[i]],
 ' ',studentrec.engscore[ID[i]],' ',studentrec.genscore[ID[i]],' ',studentrec.totalscore[ID[i]],' ',studentrec.percentageaverage[ID[i]]);

 end;
 Close(studentscorefile);
 //outputing result to the screen
  for i:=1 to 5 do
 begin
  writeln(studentrec.Examno[ID[i]],' ',studentrec.name[ID[i]],' ',studentrec.mathscore[ID[i]],
 ' ',studentrec.engscore[ID[i]],' ',studentrec.genscore[ID[i]],' ',studentrec.totalscore[ID[i]],' ',studentrec.percentageaverage[ID[i]]);

 end;
READLN;
end.
avatar
Morris
Admin

Posts : 19
Join date : 2012-07-06
Age : 27
Location : BENIN CITY

View user profile http://codersvilla.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum