Program Squares; {Leonidas Georgiou, 17/12/06, 1CS } Var Infile, Outfile:text; A:char; B,C,D,E:Integer; {Function 1 for Calculating the Sum of the Cubes / C } Function Cubesum(B,C,D,E:integer):Integer; Begin Cubesum:=B*C*D*3+E*E*E; End; {Function 2 for calculating the sum of the Sqares / S } function Sqrsum(B,C,D,E:integer):Integer; begin Sqrsum:=B*C*3+E*E; End; {Function 3 for calculating the Average Sum / A } function Avsqrsum(B,C,D,E:integer):Real; Begin Avsqrsum:=(B+C+D+E)/4; End; { Main program } Begin Assign (Infile,'c:\skt.txt'); Assign (Outfile,'c:\mlkia.txt'); Reset(Infile); Rewrite(Outfile); while (not eof(infile))do Readln(infile,A,B,C,D,E); if A='C'then Writeln(outfile,cubesum(B,C,D,E),' Sum of the cubes'); if A='S' then Writeln(outfile,sqrsum(B,C,D,E),' Sum of Square'); if A='A' then Writeln(outfile,avsqrsum(B,C,D,E),' Avarage of the squares'); end; Close(outfile); Close(infile); end.