Question
Belong to each section in main.rb; A sample hash data structure including student names, courses taken and grades is given. It is the printing of
Belong to each section in main.rb; A sample hash data structure including student names, courses taken and grades is given. It is the printing of the results on the screen according to the sample requests entered from the keyboard requested from you.
Sample requests:
If COURSE grade_average (eg Programming grade_average) is written, the GPA of the people who took the given course will be written.
If COURSE ogr_list (eg Programming ogr_list) is written, it will be written on the screen with a hash data structure, who took the course from which department.
Examples: echo Programming grade_average | ruby main.rb {"Programming"=>[40, 45, 75, 75, 95]} 66
echo Programming ogr_list | ruby main.rb {"Computer"=>["Ahmet Ekinci", "Mehmet Mutlu"], "Electricity"=>["Mehmet Yilmaz"], "Machinery"=>["Ayse Mutlu", "Betul Yildiz"]}
echo Physics grade_average | ruby main.rb {"Physics"=>[75, 55, 50]} 60
Note: You are expected to use the each_value method at least in one part of the assignment. Code is below.
students = { 'Computer' => { 'name' => ['Ahmet Ekinci', 'Mehmet Mutlu', 'Zeynep Yorulmaz'], 'note' => [[50, 40, 75], [30, 80, 45], [90, 65, 55]], 'courses taken' => [['Math', 'Programming', 'Physics'], ['Math', 'Computer Eng. Introduction', 'Programming'], ['Foreign Language', 'Computer Eng. Introduction', 'Physics']] }, 'Electricity' => { 'name' => ['Ali Kilic', 'Mehmet Yilmaz'], 'note' => [[60, 75], [40, 75]], 'courses taken' => [['Math', 'EMT'], ['EMT', 'Programming']] }, 'machine' => { 'name' => ['Ayse Mutlu', 'Betul Yildiz'], 'note' => [[45, 75], [30, 95, 50]], 'courses taken' => [['Math', 'Programming'], ['Chemistry', 'Programming', 'Physics']] } } def points_courses(students, course) # Production of glossary of course names (courses) and course grades (points) based on students and course given points, courses = {}, {}
=== WRITE CODE === [points, courses] end
course, requested = gets.chomp.split
points, courses = points_courses(students, course) # Sample outputs: courses = {"Computer"=>["Ahmet Ekinci", "Mehmet Mutlu"], "Electricity"=>["Mehmet Yilmaz"], "Machinery"=>["Ayse Mutlu", "Betul Yildiz" "]} # points = {"Programming"=>[40, 45, 75, 75, 95]}
=== WRITE CODE ===
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started