Progmram Ruby sederhana

Tuesday, 11 May 20100 comments


DIbawah ini contoh program ruby untuk mengintput nilai dari mahasiswa dan menentukan gradenya sesuai dengan nilai,
LISTING PROGRAM
nama=[]
npm=[]
uts=[]
uas=[]
grade=[]
total=[]
print "Masukkan banyak data : "
jum=gets.to_i
print "\n"
for i in 1..jum
print "Masukkan nama ke-",i,":"
nama[i]=gets
print "Masukkan npm ke-",i,":"
npm[i]=gets.to_i
print "Masukkan uts ke-",i,":"
uts[i]=gets.to_i
print "Masukkan uas ke-",i,":"
uas[i]=gets.to_i
total[i]=(0.7*uts[i])+(0.3*uas[i])
print "\n"
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
end
for i in 1..jum
print "Nama ke-",i,":",nama[i]
print "NPM ke-",i,":",npm[i],"\n"
print "UTS ke-",i,":",uts [i],"\n"
print "UAS ke-",i,":",uas [i],"\n"
print "Total : ",total[i],"\n"
print "Grade anda : ", grade[i],"\n","\n"
end
Donasi Pada Blog Ini Cukup Mengklik Iklan Yang Ada, Klik Anda Sangat Berguna Untuk Kelangsungan Blog Ini. Terima Kasih

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. BANYAK HAL - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger