ANGKA KE TULISAN

uses crt;
var angka : integer;
kata  : string;
SAngka,jenis : string;

function IntToStr(I: Longint): String;
var
S: string[11];
begin
Str(I, S);
IntToStr := S;
end;

procedure cekdigit(SAngka : string);
var digit : integer;
jenis : string;
begin
SAngka := IntToStr(angka);
digit := length(SAngka);
case digit of
1  : jenis := ‘se’;
2  : jenis := ‘puluh’;
3  : jenis := ‘ratus’;
4  : jenis := ‘ribu’;
5  : jenis := ‘juta’;
6  : jenis := ‘milyard’;
12 : jenis := ‘trilyun’;
end;
end;

function UbahKeKata(SAngka : string) : string;
var i,digit : byte;
kalimat,kata : string;

begin
kalimat := ”;
for i := 1 to length(SAngka) do
begin
case SAngka[i] of
‘0’ : kata := ‘ ‘;
‘1’ : begin
if i < length(SAngka) then kata := ‘ se’ else kata := ‘ satu’;
end;
‘2’ : kata := ‘ dua’;
‘3’ : kata := ‘ tiga’;
‘4’ : kata := ‘ empat’;
‘5’ : kata := ‘ lima’;
‘6’ : kata := ‘ enam’;
‘7’ : kata := ‘ tujuh’;
‘8’ : kata := ‘ delapan’;
‘9’ : kata := ‘ sembilan’;
end;
kalimat := kalimat + kata;
digit := length(SAngka) – i;
case digit of
0  : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ ‘;
delete(kalimat,(length(kalimat)-4),2);
end;
1  : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ puluh’;
kalimat := kalimat + jenis;
end;
2  : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ ratus’;
kalimat := kalimat + jenis;
end;
3  : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ ribu’;
kalimat := kalimat + jenis;
end;
6  : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ juta’;
kalimat := kalimat + jenis;
end;
9  : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ milyard’;
kalimat := kalimat + jenis;
end;
12 : if SAngka[i] <> ‘0’ then
begin
jenis := ‘ trilyun’;
kalimat := kalimat + jenis;
end;
end;

end;
UbahKeKata := kalimat;
end;

begin
clrscr;
write(‘Ketikkan angka (1 digit) :’);readln(Sangka);
{ SAngka := IntToStr(angka);}
kata := UbahKeKata(SAngka);
writeln(kata);
readln;
end.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: