procedure N3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject; var Key: Char);
procedure N4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses main;
{$R *.dfm}
var x,y,numb,cyf,m:real;
oper,f:integer;
procedure TForm3.Butt_0Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '0';
f:= 1;
end
else
if Edit1.Text <> '0'
then Edit1.Text:= Edit1.Text + '0';
end;
procedure TForm3.Butt_1Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '1';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '1';
end;
procedure TForm3.Butt_2Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '2';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '2';
end;
procedure TForm3.Butt_3Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '3';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '3';
end;
procedure TForm3.Butt_4Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '4';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '4';
end;
procedure TForm3.Butt_5Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '5';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '5';
end;
procedure TForm3.Butt_6Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '6';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '6';
end;
procedure TForm3.Butt_7Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '7';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '7';
end;
procedure TForm3.Butt_8Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '8';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '8';
end;
procedure TForm3.Butt_9Click(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:= '9';
f:= 1;
end
else Edit1.Text:= Edit1.Text + '9';
end;
procedure DoOper;
begin
numb:= StrToFloat(Form3.Edit1.Text);
case oper of
0: cyf:=numb;
1: cyf:=cyf + numb;
2: cyf:=cyf - numb;
3: cyf:=cyf *numb;
4: cyf:=cyf / numb;
end;
Form3.Edit1.Text:= FloatToStr(cyf);
end;
procedure TForm3.Butt_MCClick(Sender: TObject);
begin
m:=0;
panel1.Caption:='';
end;
procedure TForm3.Butt_MRClick(Sender: TObject);
begin
edit1.Text:=floattostr(M);
end;
procedure TForm3.Butt_MSClick(Sender: TObject);
begin
M:=strtofloat(edit1.Text);
panel1.Caption:='M';
end;
procedure TForm3.Butt_M_plusClick(Sender: TObject);
begin
panel1.Caption:='M';
M:=M+strtofloat(edit1.Text);
end;
procedure TForm3.Butt_backClick(Sender: TObject);
var
back:string;
begin
back:=edit1.Text;
delete(back,length(back),1);
edit1.Text:=back;
if edit1.Text='' then
begin
edit1.Text:='0';
end;
end;
procedure TForm3.Butt_CClick(Sender: TObject);
begin
Edit1.Text:= '0';
cyf:= 0;
oper:= 0;
f:= 0;
end;
procedure TForm3.Butt_plus_minusClick(Sender: TObject);
begin
edit1.Text:=floattostr(-strtofloat(edit1.Text));
end;
procedure TForm3.Butt_comaClick(Sender: TObject);
begin
if Edit1.Text = '0' then
begin
Edit1.Text:= '0,';
f:= 1;
end;
if Pos(',',Edit1.Text) = 0 then
Edit1.Text:= Edit1.Text + ',';
end;
procedure TForm3.Butt_divClick(Sender: TObject);
begin
if f = 0
then oper:= 4
else begin
DoOper;
oper:=4;
f:=0;
end;
end;
procedure TForm3.Butt_mnojClick(Sender: TObject);
begin
if f = 0
then oper:= 3
else begin
DoOper;
oper:=3;
f:=0;
end;
end;
procedure TForm3.Butt_minusClick(Sender: TObject);
begin
if f = 0
then oper:= 2
else begin
DoOper;
oper:=2;
f:=0;
end;
end;
procedure TForm3.Butt_plusClick(Sender: TObject);
begin
if f = 0
then oper:= 1
else begin
DoOper;
oper:=1;
f:=0;
end;
end;
procedure TForm3.Butt_sqrt_corinClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
if (x<0) then
begin
messagedlg('Квадратного кореня з від*ємного числа неіснує!',mtError,[mbOk],0); exit;
end;
y:=sqrt(x);
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.Butt_stepClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
y:=sqr(x);
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.Butt_na_xClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
y:=1/x;
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.Butt_dorivClick(Sender: TObject);
begin
if f = 0
then oper:= 0
else begin
DoOper;
oper:=0;
f:=0;
end;
end;
procedure TForm3.Butt_piClick(Sender: TObject);
begin
if f = 0
then begin
Edit1.Text:=floattostr(pi);
f:= 1;
end
else
if Edit1.Text <> '1'
then Edit1.Text:= Edit1.Text + '';
end;
procedure TForm3.Butt_sinClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
y:=sin(x);
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.Butt_lnClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
if (x<1) then
begin
messagedlg('Логарифм від"ємного числа не існує!',mtError,[mbOk],0); exit;
end;
y:=ln(x);
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.Butt_cosClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
y:=cos(x);
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.Butt_xClick(Sender: TObject);
begin
x:=StrToFloat(form3.Edit1.Text);
y:=exp(x);
Form3.Edit1.Text:=FloatToStr(y);
end;
procedure TForm3.N2Click(Sender: TObject);
begin
Form3.Edit1.Width:=249;
Form3.Width:=266;
end;
procedure TForm3.N3Click(Sender: TObject);
begin
Form3.Edit1.Width:=320;
Form3.Width:=339;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
oper:= 0;
end;
proсedure TForm3.Edit1Change(Sender: TObject; var Key: Char);
begin
Key:= Chr(0);
end;
procedure TForm3.N4Click(Sender: TObject);
begin
Form3.Close;
end;
end.