Listing LA Ruby,,
a = "Y"
while a == "Y" or a == "y"
puts "menu pilihan"
puts "1. program nilai"
puts "2. program gesitiga siku-siku"
puts "3. program segitiga sama sisi"
print " masukan pilihan : "
x = gets.to_i
if x == 1
print "masukan nama : "
c = gets.to_s
print "masukan nilai UAS : "
d = gets.to_i
print "masukan nilai UTS : "
e = gets.to_i
f = (d + e) / 2
if f >= 85
puts "grade anda A"
elsif f >= 70
puts "grade anda B"
elsif f >= 60
puts "grade anda C"
elsif f >= 50
puts "grade anda D"
else
puts "grade anda E"
end
elsif x == 2
print "masukan tinggi segitiga : "
g = gets.to_i
for i in 1..g
for j in 1..i
print " *"
end
print "\n"
g += 1
end
elsif x == 3
print "masukan tinggi segitiga : "
k = gets.to_i ; n = k
for i in 1..k
for l in 1..n
print " "
end
for j in 1..i
print " *"
end
print "\n"
n = n - 1
end
else
print "anda salah input"
end
print "mau coba lagi ? (y/n) ? "
a=gets;a.chop!
end
buat outpunya coba sendiri iya teman - teman :)
a = "Y"
while a == "Y" or a == "y"
puts "menu pilihan"
puts "1. program nilai"
puts "2. program gesitiga siku-siku"
puts "3. program segitiga sama sisi"
print " masukan pilihan : "
x = gets.to_i
if x == 1
print "masukan nama : "
c = gets.to_s
print "masukan nilai UAS : "
d = gets.to_i
print "masukan nilai UTS : "
e = gets.to_i
f = (d + e) / 2
if f >= 85
puts "grade anda A"
elsif f >= 70
puts "grade anda B"
elsif f >= 60
puts "grade anda C"
elsif f >= 50
puts "grade anda D"
else
puts "grade anda E"
end
elsif x == 2
print "masukan tinggi segitiga : "
g = gets.to_i
for i in 1..g
for j in 1..i
print " *"
end
print "\n"
g += 1
end
elsif x == 3
print "masukan tinggi segitiga : "
k = gets.to_i ; n = k
for i in 1..k
for l in 1..n
print " "
end
for j in 1..i
print " *"
end
print "\n"
n = n - 1
end
else
print "anda salah input"
end
print "mau coba lagi ? (y/n) ? "
a=gets;a.chop!
end
buat outpunya coba sendiri iya teman - teman :)
0 komentar:
Posting Komentar