Desimal ke Romawi
Labels:
kumpulan program pascal
program desimal_romawi_pakai_fungsi_if;
var des,B : integer;
ul : string;
rom : string;
Begin
writeln('PROGRAM KONVERSI DESIMAL MENJADI ROMAWI');
writeln('=======================================');
writeln;
write('Masukkan bilangan antara [1...9999] : ');
readln(des);
rom:='';
B:=des;
if (B>0) and (B<=10000) then begin while (B>0) do
begin
if (B>=1000) then
begin
B:=B-1000;
Rom:=Rom+'M';
end
else if (B>=900) then
begin
B:=B-900;
Rom:=Rom+'CM';
end
else if (B>=500) then
begin
B:=B-500;
Rom:=Rom+'D';
end
else if (B>=400) then
begin
B:=B-400;
Rom:=Rom+'CD';
end
else if (B>=100) then
begin
B:=B-900;
Rom:=Rom+'C';
end
else if (B>=90) then
begin
B:=B-90;
Rom:=Rom+'XC';
end
else if (B>=50) then
begin
B:=B-50;
Rom:=Rom+'L';
end
else if (B>=40) then
begin
B:=B-40;
Rom:=Rom+'XL';
end
else if (B>=10) then
begin
B:=B-10;
Rom:=Rom+'X';
end
else if (B>=9) then
begin
B:=B-9;
Rom:=Rom+'IX';
end
else if (B>=5) then
begin
B:=B-5;
Rom:=Rom+'V';
end
else if (B>=4) then
begin
B:=B-4;
Rom:=Rom+'IV';
end
else if (B>=1) then
begin
B:=B-1;
Rom:=Rom+'I';
end
else
B:=B-1;
end;
writeln('Desimal ',des,' = ',rom,' Romawi');
writeln;
end;
readln;
End.
Subscribe to:
Post Comments (Atom)






0 comments:
Post a Comment