nama = []
npm = []
uts = []
uas = []
total = []
grade = []
def input (nama, npm, uts, uas, n)
for i in 1..n
print "Masukkan nama ke-", i, " : "
nama [i] = gets.to_s
print "Masukkan npm ke-", i, " : "
npm [i] = gets.to_i
print "Masukkan nilai UTS ", i, " : "
uts [i] = gets.to_i
print "Masukkan nilai UAS ", i, " : "
uas [i] = gets.to_i
puts ""
end
end
def hitung (uts, uas, total, grade, n)
for i in 1..n
total [i] = ((0.7 * uts [i])+(0.3 * uas [i]))
if total [i] >= 90
grade [i] = "A"
elsif total [i] >= 80
grade [i] = "B"
elsif total [i] >= 70
grade [i] = "C"
elsif total [i] >= 60
grade [i] = "D"
else
grade [i] = "E"
end
puts " Penghitungan selesai..."
puts ""
end
end
def cetak (nama, npm, uts, uas, total, grade, n)
for i in 1..n
puts "Nama Anda : ", nama[i]
puts "NPM : ", npm [i]
puts "Nilai UTS = ", uts [i]
puts "Nilai UAS = ", uas [i]
puts "Nilai total = ", total [i]
puts "Grade : ", grade [i]
puts ""
end
end
keluar = false
while keluar == false
puts "--MENU--"
puts "1. Input"
puts "2. Hitung"
puts "3. Cetak"
puts "4. Keluar"
print "Masukkan pilihan : "
pil = gets.to_i
if pil == 1
print " Masukkan banyak data = "
n = gets.to_i
print ""
input(nama, npm, uts, uas, n)
next
elsif pil == 2
hitung(uts, uas, total, grade, n)
next
elsif pil == 3
cetak(nama, npm, uts, uas, total, grade, n)
next
else
puts "Terima kasih telah menggunakan program ini ^.^"
keluar = true
end
end
npm = []
uts = []
uas = []
total = []
grade = []
def input (nama, npm, uts, uas, n)
for i in 1..n
print "Masukkan nama ke-", i, " : "
nama [i] = gets.to_s
print "Masukkan npm ke-", i, " : "
npm [i] = gets.to_i
print "Masukkan nilai UTS ", i, " : "
uts [i] = gets.to_i
print "Masukkan nilai UAS ", i, " : "
uas [i] = gets.to_i
puts ""
end
end
def hitung (uts, uas, total, grade, n)
for i in 1..n
total [i] = ((0.7 * uts [i])+(0.3 * uas [i]))
if total [i] >= 90
grade [i] = "A"
elsif total [i] >= 80
grade [i] = "B"
elsif total [i] >= 70
grade [i] = "C"
elsif total [i] >= 60
grade [i] = "D"
else
grade [i] = "E"
end
puts " Penghitungan selesai..."
puts ""
end
end
def cetak (nama, npm, uts, uas, total, grade, n)
for i in 1..n
puts "Nama Anda : ", nama[i]
puts "NPM : ", npm [i]
puts "Nilai UTS = ", uts [i]
puts "Nilai UAS = ", uas [i]
puts "Nilai total = ", total [i]
puts "Grade : ", grade [i]
puts ""
end
end
keluar = false
while keluar == false
puts "--MENU--"
puts "1. Input"
puts "2. Hitung"
puts "3. Cetak"
puts "4. Keluar"
print "Masukkan pilihan : "
pil = gets.to_i
if pil == 1
print " Masukkan banyak data = "
n = gets.to_i
print ""
input(nama, npm, uts, uas, n)
next
elsif pil == 2
hitung(uts, uas, total, grade, n)
next
elsif pil == 3
cetak(nama, npm, uts, uas, total, grade, n)
next
else
puts "Terima kasih telah menggunakan program ini ^.^"
keluar = true
end
end
No comments:
Post a Comment