Ýëåêòð òîãûíûң êåäåðã³ñ³í àíûқòàó æîáà құðó.

unit sopr_;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ExtCtrls;

 

type

  TForm1 = class(TForm)

    Label2: TLabel;

    Edit1: TEdit;

    Label3: TLabel;

    Edit2: TEdit;

    RadioGroup1: TRadioGroup;

    Button1: TButton;

    RadioButton1: TRadioButton;

    RadioButton2: TRadioButton;

    Label4: TLabel;

    Label1: TLabel;

    procedure Button1Click(Sender: TObject);

    procedure RadioButton1Click(Sender: TObject);

    procedure RadioButton2Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

procedure TForm1.Button1Click(Sender: TObject);

var

    r1,r2: real;

    r: real;   

begin

    r1 := StrToFloat(Edit1.Text);

    r2 := StrToFloat(Edit2.Text);

    if (r1 = 0) and (r2 = 0) then

    begin

        ShowMessage('Íàäî çàäàòü âåëè÷èíó õîòÿ áû îäíîãî ñîïðîòèâëåíèÿ');

        exit;

    end;

    if RadioButton1.Checked

        then

            r:= r1+r2

        else

            r:= (r1*r2)/(r1+r2);

    Label4.Caption := 'Ñîïðîòèâëåíèå öåïè: ';

    if r < 1000 then

       Label4.Caption := Label4.Caption +

                   FloatToStrF(r,ffGeneral,3,2) + ' Îì'

    else

        begin

            r:=r/1000;

            Label4.Caption := Form1.Label4.Caption +

                   FloatToStrF(r,ffGeneral,3,2) + ' êÎì';

        end

end;

procedure TForm1.RadioButton1Click(Sender: TObject);

begin

   Label4.Caption := '';

end;

 

procedure TForm1.RadioButton2Click(Sender: TObject);

begin

      Label4.Caption := '';

end;