Untuk Membuat program menghitung rumah pada bahasa pemrograman Ruby, berikut codingannya monggo langsung ja cekidot --->
Listing program
print "*****MENGHITUNG
RUMAH*****"
puts
print "Masukan nilai : "
nilai = gets.to_i
nilai2=nilai
for a in 1..nilai
for b in 1..nilai2
print" "
end
nilai2 = nilai2-1
for c in 1..a
print"^ "
end
for d in 1..nilai
print "\\_\\"
end
puts
end
nilai3 = nilai-2
for d in 1..nilai3
print" "
if d == 1
for a in 1..nilai
print"& "
end
elsif d == nilai3
for b in 1..nilai
print"= "
end
else
for e in 1..nilai
if(e == 1)or(e == nilai)
print"& "
else
print" "
end
end
end
for a in 1..nilai
print"|#{a}|"
end
puts
end
0 komentar:
Posting Komentar