You are on page 1of 4

// ttl_demmand := StrToInt(d1.Text) + StrToInt(d2.Text) + StrToInt(d3.Text) + St rToInt(d4.Text) + StrToInt(d5.Text) + StrToInt(d6.Text); //ttl_supply := StrToInt(s1.Text) + StrToInt(s2.Text) + StrToInt(s3.

Text); // if ttl_demmand <> ttl_supply then // begin //ShowMessage('Total permintaan berbeda dengan total kapasitas pabrik'); //end; ======= unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; biaya11: TEdit; biaya12: TEdit; biaya13: TEdit; biaya14: TEdit; biaya15: TEdit; biaya16: TEdit; biaya21: TEdit; biaya22: TEdit; biaya23: TEdit; biaya24: TEdit; biaya25: TEdit; biaya26: TEdit; biaya31: TEdit; biaya32: TEdit; biaya33: TEdit; biaya34: TEdit; biaya35: TEdit; biaya36: TEdit; kapasitas1: TEdit; kapasitas2: TEdit; kapasitas3: TEdit; permintaan1: TEdit; permintaan2: TEdit; permintaan3: TEdit; permintaan4: TEdit; permintaan5: TEdit; permintaan6: TEdit; Button1: TButton;

Label13: TLabel; Label14: TLabel; hasil: TEdit; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure biaya11Change(Sender: TObject); procedure biaya12Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); const jumlah_pabrik = 3; jumlah_gudang = 6; var total_permintaan, total_kapasitas : integer; i, j : integer; item, harga, total_biaya : integer; gudang : array [1..jumlah_gudang] of integer; pabrik : array [1..jumlah_pabrik] of integer; biaya_kirim : array [1..jumlah_pabrik, 1..jumlah_gudang] of integer; begin total_permintaan := StrToInt(permintaan1.Text) + StrToInt(permintaan2.Text) + StrToInt(permintaan3.Text) + StrToInt(permintaan4.Text) + StrToInt(permintaan5.T ext) + StrToInt(permintaan6.Text); total_kapasitas := StrToInt(kapasitas1.Text) + StrToInt(kapasitas2.Text) + Str ToInt(kapasitas3.Text); if total_permintaan <> total_kapasitas then begin ShowMessage('Total permintaan berbeda dengan total kapasitas pabrik'); end; pabrik[1] := StrToInt(kapasitas1.Text); pabrik[2] := StrToInt(kapasitas2.Text); pabrik[3] := StrToInt(kapasitas3.Text); gudang[1] gudang[2] gudang[3] gudang[4] gudang[5] gudang[6] := := := := := := StrToInt(permintaan1.Text); StrToInt(permintaan2.Text); StrToInt(permintaan3.Text); StrToInt(permintaan4.Text); StrToInt(permintaan5.Text); StrToInt(permintaan6.Text); := := := := := := := StrToInt(biaya11.Text); StrToInt(biaya12.Text); StrToInt(biaya13.Text); StrToInt(biaya14.Text); StrToInt(biaya15.Text); StrToInt(biaya16.Text); StrToInt(biaya21.Text);

biaya_kirim[1,1] biaya_kirim[1,2] biaya_kirim[1,3] biaya_kirim[1,4] biaya_kirim[1,5] biaya_kirim[1,6] biaya_kirim[2,1]

biaya_kirim[2,2] biaya_kirim[2,3] biaya_kirim[2,4] biaya_kirim[2,5] biaya_kirim[2,6] biaya_kirim[3,1] biaya_kirim[3,2] biaya_kirim[3,3] biaya_kirim[3,4] biaya_kirim[3,5] biaya_kirim[3,6]

:= := := := := := := := := := :=

StrToInt(biaya22.Text); StrToInt(biaya23.Text); StrToInt(biaya24.Text); StrToInt(biaya25.Text); StrToInt(biaya26.Text); StrToInt(biaya31.Text); StrToInt(biaya32.Text); StrToInt(biaya33.Text); StrToInt(biaya34.Text); StrToInt(biaya35.Text); StrToInt(biaya36.Text);

for i:=1 to jumlah_pabrik do begin if pabrik[i] > 0 then begin for j:=1 to jumlah_gudang do begin if gudang[j] > 0 then begin if gudang[j] = 0 then begin if gudang[j+1] <= pabrik[i] then item := gudang[j+1] else item := pabrik[i]; gudang[j+1] := gudang[j+1] - item; pabrik[i] := pabrik[i] - item; harga := item * biaya_kirim[i,j]; total_biaya := total_biaya + harga; end else begin if gudang[j] <= pabrik[i] then item := gudang[j] else item := pabrik[i]; gudang[j] := gudang[j] - item; pabrik[i] := pabrik[i] - item; harga := item * biaya_kirim[i,j]; total_biaya := total_biaya + harga; end; end; end; end; end; hasil.Text:= IntToStr(total_biaya); end; procedure TForm1.FormCreate(Sender: TObject); begin end; procedure TForm1.biaya11Change(Sender: TObject); begin end; procedure TForm1.biaya12Change(Sender: TObject); begin

end; end.