-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14. oopkelas.rb
43 lines (36 loc) · 973 Bytes
/
14. oopkelas.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Mhs
def initialize(c)
@nim = [], @nama = [], @nil = []
@jum = c
end
def ambilData
a = 0
while a < @jum
puts "Data Ke-#{a+1}"
puts "-------------"
print " -> NIM [input] : "
@nim[a] = gets.chomp
print " -> Nama [input] : "
@nama[a] = gets.chomp
print " -> Nilai [input] : "
@nil[a] = gets.chomp.to_i
a += 1
end
puts "------------------------------"
puts "Isi data : "
puts "-------------"
a = 0
while a < @jum
print "[#{a+1}] NIM : #{@nim[a]} => Nama : #{@nama[a]} "
if @nil[a] > 80
puts "=> (#{@nil[a]}) Grade A"
end
a += 1
end
end
end
print "Jumlah Data [input] : "
jum = gets.chomp.to_i
puts "--------------------------"
mahasiswa = Mhs.new(jum)
mahasiswa.ambilData()