MegastoRM

sukurac glupi zadatak

Jun 17th, 2015
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
  9. StdCtrls;
  10.  
  11. type
  12.  
  13. { TForm1 }
  14.  
  15. TOcene = Array[1..6] of integer;
  16. TForm1 = class(TForm)
  17. Button1: TButton;
  18. Label1: TLabel;
  19. Label10: TLabel;
  20. Label11: TLabel;
  21. Label12: TLabel;
  22. Label2: TLabel;
  23. Label3: TLabel;
  24. Label4: TLabel;
  25. Label5: TLabel;
  26. Label6: TLabel;
  27. Label7: TLabel;
  28. Label8: TLabel;
  29. Label9: TLabel;
  30. StringGrid1: TStringGrid;
  31. procedure Button1Click(Sender: TObject);
  32. private
  33. { private declarations }
  34. procedure IspisiProsecneOcene;
  35. public
  36. { public declarations }
  37. end;
  38.  
  39. //procedure ProsekOcena(n:integer;var r:integer);
  40. var
  41. ocene:Tocene;
  42. n:integer;
  43. Form1: TForm1;
  44.  
  45. implementation
  46.  
  47. {$R *.lfm}
  48.  
  49. { TForm1 }
  50.  
  51. procedure TForm1.Button1Click(Sender: TObject);
  52. begin
  53. Form1.IspisiProsecneOcene;
  54. end;
  55.  
  56. procedure TForm1.IspisiProsecneOcene;
  57. var j, brojac, x, suma : integer;
  58. r : real;
  59. LabelRezultat : TLabel;
  60. ZbirSvihOcena : Integer;
  61. begin
  62. ZbirSvihOcena := 0;
  63. for x := 1 to StringGrid1.RowCount - 1 do
  64. begin
  65. suma := 0;
  66. brojac := 0;
  67. StringGrid1.Row := x;
  68.  
  69. for j := 1 to 6 do
  70. begin
  71. TryStrToInt(StringGrid1.Cells[j,x], ocene[j]);
  72. suma := suma + ocene[j];
  73. if ocene[j] > 0 then
  74. brojac := brojac + 1;
  75. end;
  76. r := (suma)/brojac;
  77. if x = 0 then
  78. LabelRezultat := Label1
  79. else if x = 1 then
  80. LabelRezultat := Label2
  81. else if x = 2 then
  82. LabelRezultat := Label3
  83. else if x = 3 then
  84. LabelRezultat := Label4
  85. else if x = 4 then
  86. LabelRezultat := Label5
  87. else if x = 5 then
  88. LabelRezultat := Label6
  89. else if x = 6 then
  90. LabelRezultat := Label7
  91. else if x = 7 then
  92. LabelRezultat := Label8
  93. else if x = 8 then
  94. LabelRezultat := Label9
  95. else if x = 9 then
  96. LabelRezultat := Label10
  97. else
  98. LabelRezultat := Label11;
  99.  
  100. ZbirSvihOcena := ZbirSvihOcena + Round(r);
  101. LabelRezultat.Caption := IntToStr(Round(r));
  102. end;
  103. r := ZbirSvihOcena / (StringGrid1.RowCount - 1);
  104. Label12.Caption := 'Prosek: ' + FloatToStr(r);
  105. end;
  106.  
  107. end.
Advertisement
Add Comment
Please, Sign In to add comment