{author : arickanjass
gunadarma university
dont copy without trademark!}
program konversi_angka_arickanjass;
uses crt;
var
masuk,angka,tmp,batas : integer;
b,c : string;
procedure convert;
begin
if angka = 0 then
c := 'nol'
else
if angka = 1 then
c := 'satu'
else
if angka = 2 then
c := 'dua'
else
if angka = 3 then
c := 'tiga'
else
if angka = 4 then
c := 'empat'
else
if angka = 5 then
c := 'lima'
else
if angka = 6 then
c := 'enam'
else
if angka = 7 then
c := 'tujuh'
else
if angka = 8 then
c := 'delapan'
else
if angka = 9 then
c := 'sembilan'
end;
{author : arickanjass
gunadarma university
dont copy without trademark!}
procedure belasan;
begin
case masuk of
10 : c := 'sepuluh';
11 : c := 'sebelas';
12 : c := 'dua belas';
13 : c := 'tiga belas';
14 : c := 'empat belas';
15 : c := 'lima belas';
16 : c := 'enam belas';
17 : c := 'tujuh belas';
18 : c := 'delapan belas';
19 : c := 'sembilan belas';
end;
end;
procedure puluhribuan;
begin
if masuk > 10000 then
begin
angka := (masuk div 1000);
tmp := masuk;
masuk := angka;
belasan;
b := concat(b,c,' ribu ');
masuk := tmp - (angka * 1000);
end
end;
procedure ribuan;
begin
if (masuk div 1000) = 1 then
begin
b:= concat (b, 'seribu ');
masuk := masuk - 1000;
end
else
begin
angka := (masuk div 1000);
convert;
b := concat (b,c,' ribu ');
masuk := masuk - (angka * 1000);
end
end;
{author : arickanjass
gunadarma university
dont copy without trademark!}
procedure ratusan;
begin
if (masuk div 100) = 1 then
begin
b:= concat (b,'seratus ');
masuk := masuk - 100;
end
else
begin
angka := (masuk div 100);
convert;
b := concat (b,c,' ratus ');
masuk := masuk - (angka * 100);
end
end;
procedure puluhan;
begin
if masuk < 20 then
belasan
else
begin
angka := (masuk div 10);
convert;
b := concat (b,c,' puluh ');
masuk := masuk - (angka * 10);
end;
end;
procedure satuan;
begin
angka := masuk;
if angka > 0 then
begin
convert;
b := concat (b,c);
end
else
b := b
end;
begin
clrscr;
write ('masukkan angka 0 - 19999 : ');
readln (masuk);
if masuk > 19999 then
writeln ('otak gua belom sampe segitu bro')
else
if masuk < 0 then
writeln ('itu minus bro, gua belom sampe situ')
else
{author : arickanjass
gunadarma university
dont copy without trademark!}
if masuk = 10000 then
b := ('sepuluh ribu')
else
if masuk > 10000 then
begin
puluhribuan;
if masuk = 0 then
b:= b
else
begin
if masuk div 100 > 0 then
ratusan;
puluhan;
satuan;
end
end
else
if masuk >= 1000 then
begin
ribuan;
if masuk = 0 then
b := b
else
begin
if (masuk div 100) > 0 then
ratusan;
puluhan;
satuan;
end
end
else
if masuk >= 100 then
begin
ratusan;
puluhan;
satuan;
end
else
if masuk >= 10 then
begin
puluhan;
satuan;
end
else
if masuk > 0 then
satuan
else
b := 'nol';
writeln (b);
readln;
end.