• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Sourceaboutmycalculatorbydelphi

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
最简单的Delphi程序(Windows)发布时间:2022-07-18
下一篇:
Delphi编程常用快捷键大全发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap