unit uyuohui;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, System.ComponentModel;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  i:Integer;
  j,d: Real;      //j存储实付款，d存储折扣
begin
   i:=Round(StrToFloat(Edit1.Text)); //取整数部分
  case i of
     0..49:  d:=0;
     50..99:  d:=0.98;
     100..199: d:=0.95;
  else
      d:=0.9;
  end;
  j:=StrToFloat(Edit1.Text)*d;
  Edit2.Text:=FloatToStr(j);
  edit4.Text:=FloatToStr(StrToFloat(Edit3.Text)-j);
end;
(*"清除"按钮的OnClick事件处理代码*)
procedure TForm1.Button2Click(Sender: TObject);
begin
 Edit1.Text:='';
 Edit2.Text:='';
 Edit3.Text:='';
 Edit4.Text:='';
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;

end.
