contoh soal delphi:
jika harga jual minimal 200.000. maka pembeli mendapatkan potongan 10% dari harga jual dan jika kurang maka 0% potongannya.
hitunglah total bayarnya.
Rumus:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm7 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
tsatu: TEdit;
tjum: TEdit;
tbayar: TEdit;
tpotong: TEdit;
ttotal: TEdit;
Button1: TButton;
Button2: TButton;
tbeli: TEdit;
Label8: TLabel;
procedure tsatuChange(Sender: TObject);
procedure tjumChange(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TForm7.tsatuChange(Sender: TObject);
begin
if strtoint(tsatu.Text)>=200000
then
tpotong.Text:=inttostr(strtoint(tsatu.text)* 10 div 100)
else
tpotong.text:='0'
end;
procedure TForm7.tjumChange(Sender: TObject);
begin
tbayar.Text:=inttostr(strtoint(tjum.Text)*strtoint(tsatu.Text));
if strtoint(tbayar.Text)>=200000 then
tpotong.text:=inttostr(strtoint(tbayar.text)* 10 div 100)
else
tpotong.text:='0';
ttotal.text:=tbayar.text;
ttotal.text:=inttostr(strtoint(tbayar.text) - strtoint(tpotong.text))
end;
procedure TForm7.Button2Click(Sender: TObject);
begin
close
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
tjum.Text:='0';
tbayar.Text:='0';
tpotong.Text:='0';
tsatu.Text:='0';
ttotal.Text:='0';
tbeli.Text:='';
tbeli.SetFocus;
end;
end.
contoh program ketika dijalankan
jika harga jual minimal 200.000. maka pembeli mendapatkan potongan 10% dari harga jual dan jika kurang maka 0% potongannya.
hitunglah total bayarnya.
Rumus:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm7 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
tsatu: TEdit;
tjum: TEdit;
tbayar: TEdit;
tpotong: TEdit;
ttotal: TEdit;
Button1: TButton;
Button2: TButton;
tbeli: TEdit;
Label8: TLabel;
procedure tsatuChange(Sender: TObject);
procedure tjumChange(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TForm7.tsatuChange(Sender: TObject);
begin
if strtoint(tsatu.Text)>=200000
then
tpotong.Text:=inttostr(strtoint(tsatu.text)* 10 div 100)
else
tpotong.text:='0'
end;
procedure TForm7.tjumChange(Sender: TObject);
begin
tbayar.Text:=inttostr(strtoint(tjum.Text)*strtoint(tsatu.Text));
if strtoint(tbayar.Text)>=200000 then
tpotong.text:=inttostr(strtoint(tbayar.text)* 10 div 100)
else
tpotong.text:='0';
ttotal.text:=tbayar.text;
ttotal.text:=inttostr(strtoint(tbayar.text) - strtoint(tpotong.text))
end;
procedure TForm7.Button2Click(Sender: TObject);
begin
close
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
tjum.Text:='0';
tbayar.Text:='0';
tpotong.Text:='0';
tsatu.Text:='0';
ttotal.Text:='0';
tbeli.Text:='';
tbeli.SetFocus;
end;
end.
contoh program ketika dijalankan
Posting Komentar