Смекни!
smekni.com

Программа Калькулятор (стр. 2 из 2)

begin

o('1',s,s1);

edit1.text:=(' '+s)

end;

.

.

.

procedure TForm5.Button9Click(Sender: TObject);

begin

o('9',s,s1);

edit1.text:=(' '+s)

end;

procedure TForm5.Button20Click(Sender: TObject);

begin

if copy(s,1,1)='-'

then delete(s,1,1)

else s:='-'+s ;

s1:=s;

edit1.text:=(' '+s)

end;

procedure TForm5.Button16Click(Sender: TObject);

begin

val(s1,y,i);

operat(x,y,c,z);

x:=z; c:='+';

str(z:6:6,s); okr(s);

edit1.text:=(' '+s);

s:='' ;t:=0;

end;

procedure TForm5.Button21Click(Sender: TObject);

begin

val(s1,y,i);

operat(x,y,c,z);

x:=z; c:='-';

str(z:6:6,s);okr(s);

edit1.text:=(' '+s);

s:='' ;t:=0;

end;

procedure TForm5.Button15Click(Sender: TObject);

begin

val(s1,y,i);

operat(x,y,c,z);

x:=z; c:='*';

str(z:6:6,s);okr(s);

edit1.text:=(' '+s);

s:='';t:=0;

end;


procedure TForm5.Button14Click(Sender: TObject);

begin

val(s1,y,i);

operat(x,y,c,z);

x:=z; c:='/';

str(z:6:6,s); okr(s);

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button26Click(Sender: TObject);

begin

val(s1,y,i);

z:=y*y;

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button27Click(Sender: TObject);

begin

val(s1,y,i);

z:=y*y*y;

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button12Click(Sender: TObject);

begin

c:='';

t:=0;

s:='';

s1:=s;

y:=0;

edit1.text:=(' 0');

end;

procedure TForm5.Button30Click(Sender: TObject);

begin

val(s1,y,i);

z:=round(y);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button13Click(Sender: TObject);

begin

val(s1,y,i);

operat(x,y,c,z);

x:=z;

c:='';

str(z:6:6,s);

okr(s);

s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button19Click(Sender: TObject);

begin

val(s1,y,i);

if y<>0 then

begin

z:=1/y;

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

end else

begin

messagedlg('На 0 делитьнельзя',mterror,[mbok],0);

{ edit1.text:=('E ') ;}

end;

s:='';t:=0;

end;

procedure TForm5.Button37Click(Sender: TObject);

begin

t:=0;

s:='';

s1:=s;

edit1.text:=(' 0');

end;

procedure TForm5.Button18Click(Sender: TObject);

begin

val(s1,y,i);

begin

if radiobutton1.Checked then

f:=y*3.14159265359/180

else f:=y; end;

z:=cos(f);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button22Click(Sender: TObject);

begin

val(s1,y,i);

begin

if radiobutton1.Checked then

f:=y*3.14159265359/180

else f:=y; end;

z:=sin(f);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button23Click(Sender: TObject);

begin

val(s1,y,i);

if y<>0

then begin

if radiobutton1.Checked

then

f:=y*3.14159265359/180

else f:=y;

z:=sin(f)/cos(f);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

end else

begin

messagedlg('На 0 делитьнельзя',mterror,[mbok],0);

end;

s:='';t:=0;

end;

procedure TForm5.Button24Click(Sender: TObject);

begin

val(s1,y,i);

if y<>0

then begin

if radiobutton1.Checked

then

f:=y*3.14159265359/180

else f:=y;

z:=cos(f)/sin(f);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

end else

begin

messagedlg('На 0 делитьнельзя',mterror,[mbok],0);

end;

s:='';t:=0;

end;


procedure TForm5.Button25Click(Sender: TObject);

begin

val(s1,y,i);

if y>=0 then begin

z:=sqrt(y);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

end else begin

messagedlg('Кореньизотрицательногочислаизвлечьнельзя',mterror,[mbok],0);

end;

s:='';t:=0;

end;

procedure TForm5.Button28Click(Sender: TObject);

begin

val(s1,y,i);

operat(x,y,c,z);

x:=z;

c:='x^y';

str(z:6:6,s);okr(s);

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button32Click(Sender: TObject);

begin

z:=3.14159265359;

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button29Click(Sender: TObject);

begin

val(s1,y,i);

if y>=1 then begin

z:=ln(y);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

end else

begin

messagedlg('LN X<=0 неопределён',mterror,[mbok],0);

end;

s:='';t:=0;

end;

procedure TForm5.Button31Click(Sender: TObject);

var k:integer; fact:real;

begin

val(s1,y,i);

fact:=1;

k:=1;

if (y>1) and (y<=18) then

begin

y:=round(y);

repeat

k:=k+1;

fact:=fact*k;

until k=y;

end

else

begin

s:=' 0';

messagedlg('Слишком большое чиссло',mtcustom,[mbok],0);

end;

z:=round(fact);

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button38Click(Sender: TObject);

begin

val(s1,y,i); m:=m+y;

s:='';t:=0;

if m<>0 then edit2.text:=('M ')

else edit2.text:=(' ');

end;

procedure TForm5.Button39Click(Sender: TObject);

begin

val(s1,y,i); m:=m-y;

s:='';t:=0;

if m<>0 then edit2.text:=('M ')

else edit2.text:=(' ');

end;


procedure TForm5.Button34Click(Sender: TObject);

begin

val(s1,y,i); m:=y;

s:='';t:=0;

if m<>0 then edit2.text:=('M ')

else edit2.text:=(' ');

end;

procedure TForm5.Button35Click(Sender: TObject);

begin

str(m:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

procedure TForm5.Button36Click(Sender: TObject);

begin

m:=0;

if m<>0 then edit2.text:=('M ')

else edit2.text:=(' ');

end;

procedure TForm5.Button11Click(Sender: TObject);

begin

if t=0 then

begin

s:=s+'.'; s1:=s;

edit1.text:=(' '+s);

t:=1

end;

end;

procedure TForm5.RadioButton1Click(Sender: TObject);

begin

radiobutton1.checked:=true;

radiobutton2.checked:=false;

end;

procedure TForm5.RadioButton2Click(Sender: TObject);

begin

radiobutton2.checked:=true;

radiobutton1.checked:=false;

end;

procedure TForm5.Button17Click(Sender: TObject);

begin

val(s1,y,i);

z:=random;

str(z:6:6,s);okr(s);s1:=s;

edit1.text:=(' '+s);

s:='';t:=0;

end;

end.