unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Rg1: TRadioGroup; Rg2: TRadioGroup; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; e1: TEdit; e2: TEdit; e3: TEdit; E4: TLabel; GroupBox1: TGroupBox; c1: TCheckBox; c2: TCheckBox; c3: TCheckBox; GroupBox2: TGroupBox; Button1: TButton; Button2: TButton; GroupBox3: TGroupBox; Label5: TLabel; e5: TEdit; Button3: TButton; l6: TLabel; Label6: TLabel; procedure Button2Click(Sender: TObject); procedure c3Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure e1Click(Sender: TObject); procedure e1Enter(Sender: TObject); procedure e2Enter(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject); begin close; end;
function realtostr(a:real):string; var x, y:integer; begin x:=trunc(a); y:=round(a*10000-x*10000); realtostr:=inttostr(x)+'.'+inttostr(y); end;
procedure TForm1.c3Click(Sender: TObject); begin if c3.Checked then begin e2.Visible:=false; Label2.Visible:=false; rg1.Visible:=false; rg2.Visible:=true; end else begin e2.Visible:=true; Label2.Visible:=true; rg1.Visible:=true; rg2.Visible:=false; end; end;
procedure TForm1.Button1Click(Sender: TObject); var x, y, z:integer; z1:real; begin if not c3.Checked then begin try x:=strtoint(e1.Text); y:=strtoint(e2.Text); except showmessage('Input error'); exit; end;
case rg1.itemindex of 0: z:=x+y; 1: z:=x-y; 2: z:=x*y; 3: begin if y=0 then begin showmessage('Ur Divisor is 0, so error'); e3.Text:=''; exit; end; z:=x div y; end; end; e3.Text:=inttostr(z); if c2.checked and (rg1.itemindex=3) then if(x mod y<>0) then e3.text:=e3.text+'Remainder'+inttostr(x mod y); end else begin try x:=strtoint(e1.text); except showmessage('error'); exit; end; case rg2.ItemIndex of 0: z1:=sin(x); 1: z1:=cos(x); 2: begin z:=sqr(x); e3.Text:=inttostr(z); exit; end; 3: z1:=sqrt(x); 4: z1:=exp(x); end; e3.Text:=realtostr(z1); end; end;
procedure TForm1.e1Click(Sender: TObject); begin e1.Text:=''; e2.Text:=''; e3.Text:=''; end;
procedure TForm1.e1Enter(Sender: TObject); begin if c1.Checked then e1.text:=''; e3.text:=''; end;
procedure TForm1.e2Enter(Sender: TObject); begin e2.text:=''; e3.text:=''; end;
procedure TForm1.Button3Click(Sender: TObject); begin if e5.text='59502299' then begin e5.Visible:=false; button3.visible:=false; Label6.Visible:=true; button1.Visible:=true; end else e5.Visible:=false; button3.visible:=false; Label5.Visible:=true; end;
end.
|
请发表评论