Contoh Potongan Program perhitungan IPK (memakai case)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
Button3: TButton;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1Click(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
IPK:integer;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
IPK:=StrToInt(edit1.Text);
case IPK of
0..1:Edit2.Text:='KURANG';
2..3:Edit2.Text:='BAIK';
4:Edit2.Text:='SEMPURNA';
5..10:Edit2.Text:='IMPOSSIBLE';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Edit1Click(Sender: TObject);
begin
Edit1.Clear;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
If (Edit2.Text='') then Edit1.Text:='Inputkan IPK';
end;
end.
klik disini intuk download programnya
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
Button3: TButton;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1Click(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
IPK:integer;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
IPK:=StrToInt(edit1.Text);
case IPK of
0..1:Edit2.Text:='KURANG';
2..3:Edit2.Text:='BAIK';
4:Edit2.Text:='SEMPURNA';
5..10:Edit2.Text:='IMPOSSIBLE';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Edit1Click(Sender: TObject);
begin
Edit1.Clear;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
If (Edit2.Text='') then Edit1.Text:='Inputkan IPK';
end;
end.
klik disini intuk download programnya