Input jumlah uang kemudian outputkan dalam bentuk kalimat

//judul

uang yang ada di dompet

//kamus

jumUang <- long

void terbilang <- long integer x

//algoritma

input jumlah uang

terbilang(jumUang) output “Rupiah;

void terbilang(long integer x){
if(x=1){
output “Satu ”
}else if(x=2){
output “Dua”
}else if(x=3){
output “Tiga ”
}else if(x=4){
output “Empat”
}else if(x=5){
output “Lima”
}else if(x=6){
output “Enam”
}else if(x=7){
output “Tujuh”
}else if(x=8){
output “Delapan”
}else if(x=9){
output “Sembilan”
}else if(x=10){
output “Sepuluh”
}else if(x=11){
output “Sebelas”
}else if(x>=12 and x<=19){
terbilang(x mod 10)
output “Belas”
}else if(x>=20 and x<=99){
terbilang(x/10)
output “Puluh”
terbilang(x mod 10)
}else if(x>=100 and x<=199){
output “Seratus”
terbilang(x-100)
}else if(x>=200 and x<=999){
terbilang(x/100)
output”Ratus”
terbilang(x mod 100);
}else if(x>=1000 and x<=1999){
output “Seribu”
terbilang(x-1000);
}else if(x>=2000 and x<=999999){
terbilang(x/1000)
output “Ribu”
terbilang(x mod 1000);
}else if(x>=1000000 and x<=999999999){
terbilang(x/1000000)
output “Juta”
terbilang(x mod1000000)
}

Leave a Reply

Your email address will not be published. Required fields are marked *