Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
- StdCtrls;
- type
- { TForm1 }
- TOcene = Array[1..6] of integer;
- TForm1 = class(TForm)
- Button1: TButton;
- Label1: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- Label12: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- StringGrid1: TStringGrid;
- procedure Button1Click(Sender: TObject);
- private
- { private declarations }
- procedure IspisiProsecneOcene;
- public
- { public declarations }
- end;
- //procedure ProsekOcena(n:integer;var r:integer);
- var
- ocene:Tocene;
- n:integer;
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Form1.IspisiProsecneOcene;
- end;
- procedure TForm1.IspisiProsecneOcene;
- var j, brojac, x, suma : integer;
- r : real;
- LabelRezultat : TLabel;
- ZbirSvihOcena : Integer;
- begin
- ZbirSvihOcena := 0;
- for x := 1 to StringGrid1.RowCount - 1 do
- begin
- suma := 0;
- brojac := 0;
- StringGrid1.Row := x;
- for j := 1 to 6 do
- begin
- TryStrToInt(StringGrid1.Cells[j,x], ocene[j]);
- suma := suma + ocene[j];
- if ocene[j] > 0 then
- brojac := brojac + 1;
- end;
- r := (suma)/brojac;
- if x = 0 then
- LabelRezultat := Label1
- else if x = 1 then
- LabelRezultat := Label2
- else if x = 2 then
- LabelRezultat := Label3
- else if x = 3 then
- LabelRezultat := Label4
- else if x = 4 then
- LabelRezultat := Label5
- else if x = 5 then
- LabelRezultat := Label6
- else if x = 6 then
- LabelRezultat := Label7
- else if x = 7 then
- LabelRezultat := Label8
- else if x = 8 then
- LabelRezultat := Label9
- else if x = 9 then
- LabelRezultat := Label10
- else
- LabelRezultat := Label11;
- ZbirSvihOcena := ZbirSvihOcena + Round(r);
- LabelRezultat.Caption := IntToStr(Round(r));
- end;
- r := ZbirSvihOcena / (StringGrid1.RowCount - 1);
- Label12.Caption := 'Prosek: ' + FloatToStr(r);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment