{ Teresa Tong [30] F.4AS       April,2002 }
{ Process the 3 test and 1 examination marks for Computer Studies in a class of 10 students. } 

program TotalMark;
uses wincrt;
var TMark: array[1..10,1..3] of integer;
    EMark: array[1..10] of integer;    
    Total: array[1..10] of integer;
    Score: array[1..10] of integer;
    Name: array[1..10] of string;
    Remark: array[1..10] of string;
    Stud, Test, Sum, i :integer;


procedure InputData;
{ Input necessary data: Name, Test mark and exam Mark }
var Stud, Test :integer;
begin
  for Stud:=1 to 10 do
    begin
    readln(Name[Stud]);
    for Test:=1 to 3 do
    readln(Tmark[Stud, Test]);
    readln(EMark[Stud]);
  end
end;

procedure Calculation;
{ Calculate the total score of the student:
   Total = (Test1 + Test2 +Test 3)/3 * 30% + Exam * 70% } 
var Stud, Test :integer;
begin
  for Stud :=1 to 10 do
    begin
      Score[Stud]:=0;
      for Test:= 1 to 3 do
      Score[Stud] := Score[Stud] + TMark[Stud,Test];
      Total[Stud]:=round((Score[Stud]/3)*30/100 + EMark[Stud]*70/100)
      end                     
end;


procedure GiveRemark;
begin
  for Stud:=1 to 10 do
  begin
    if Total[Stud]>=70
      then Remark[Stud]:='Passed with merit'
      else if Total[Stud]>=50
           then Remark[Stud]:='Passed'
      else if Total[Stud]<50
           then Remark[Stud]:='Failed'
  end;
end;


begin
  writeln(' Input the marks as follow:');
  writeln(' " Name of the Student "');
  writeln(' " Mark of Test 1 "');
  writeln(' " Mark of Test 2 "');
  writeln(' " Mark of Test 3 "');
  writeln(' " Mark of Exam "');
  writeln;
  InputData;
  Calculation;
  GiveRemark;
  writeln;
  writeln('Name':20, 'Total':15, 'Remark':25);
  writeln;
  for Stud:=1 to 10 do
  begin
  writeln(Name[Stud]:20, Total[Stud]:15, Remark[Stud]:25)
  end
end.


============================================================
e.g.

1)  Input the marks as follow:
    " Name of the Student "
    " Mark of Test 1 "
    " Mark of Test 2 "
    " Mark of Test 3 "
    " Mark of Exam "

    Chan Siu Ling
    79
    81
    63
    70
    Chan Tai Wai
    35
    40
    53
    49
    Cheung Wai Kwong
    60
    51
    53
    53
    ...
  
                      Name         Total                       Remark

          Chan Siu Ling             71         Passed with merit
           Chan Tai Wai             47                          Failed
   Cheung wai Kwong             54                        Passed
   ...



    Source: geocities.com/ttt_7_ttt/home6

               ( geocities.com/ttt_7_ttt)