Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help with my beginner\'s Ruby code. grades Instructlons from your teacher 4 puts

ID: 3590922 • Letter: H

Question


Help with my beginner's Ruby code.

grades Instructlons from your teacher 4 puts "Enter 5 names" 5 5.times do Ixl 6 7 end 8 puts "Enter 5 grades" 9 5.times do Ixl Write a program Store the names in an array called names. that allows the user to enter 5 names names [x)=gets.chomp Then it allows the user to enter 5 grades (as floats) for those students. Store the grades in an array called grades Then output the average, the student who eamed the highest grade, and the student who earned the lowest grade. 10 grades[x] gets.chomp.to f 11 end 12 grades.each do 1xl 13 sum+x Example Input: 14 15 16 17 end avg-sum/5 puts "Average : #favg . to-f" highest-grades[] Tomai Schweller Wylie 100 €1 ruby 2.3.1p112 (2016-04-26 revision 54768) [x86 64- linux] 91 Example Output: Enter 5 names: Enter 5 grades: Average: 94.8 Highest: Eric Lowest: Chen

Explanation / Answer

h = grades.index(grades.max)

print names[h]


L = grades.index(grades.min)

print names[L]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote