Średnia ocen

Uruchom program

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Button1: TButton;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  l1,l2,l3,l4,l5,l6:integer;
  lp,sup:integer;
  sr:real;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  l1:=StrToInt(Edit1.Text);
  l2:=StrToInt(Edit2.Text);
  l3:=StrToInt(Edit3.Text);
  l4:=StrToInt(Edit4.Text);
  l5:=StrToInt(Edit5.Text);
  l6:=StrToInt(Edit6.Text);
  lp:=l1+l2+l3+l4+l5+l6;
  sup:=l1+l2*2+l3*3+l4*4+l5*5+l6*6;
  if lp=0 then exit else sr:=sup/lp;
  Edit7.Text:=FloatToStr(sr);
end;

end.