Pengikut

Rabu, 04 April 2012

Delphi(Genap,Ganjil,Prima)

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    ListBox1: TListBox;
    ListBox2: TListBox;
    ListBox3: TListBox;
    Button3: TButton;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    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,awal,akhir:Integer ;
begin
awal:=StrToInt(Edit1.Text);
akhir:=StrToInt(Edit2.Text);
for i := awal to akhir do
begin

if i mod 2=0 then
begin
ListBox1.Items.Add(IntToStr(i));
end
else
begin
if (i = 2)or(i=3)or(i=5)or(i=7)or(i>3)and(i mod 2 <> 0)and(i mod 3 <> 0
)and(i mod 5 <> 0)and(i mod 7 <> 0) then
begin
ListBox3.Items.Add(IntToStr(i));
end
else
if i mod 2=1 then
begin
ListBox2.Items.Add( IntToStr(i));
end;
Label7.Caption:= '2 = Bilangan Prima';
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
ListBox1.Clear;
ListBox2.Clear;
ListBox3.Clear;
end;

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

end.

Tidak ada komentar:

Posting Komentar

Monggo dikoment.. :)