Newer
Older
Ruby / hw-bmi.rb
@mktao2 mktao2 9 days ago 384 bytes upload all files
#!/usr/koeki/bin/ruby
# coding: utf-8
require 'csv'
require './kprintf.rb'

data = Array.new
csv = CSV.read("hw.csv")

csv.each do |row|
  name, height, weight = row[0], row[1].to_f, row[2].to_f
  bmi = weight/(height/100)**2
  data << [name, height, weight, bmi]
end
data.each do |i|		# ここをBMI値でソートしたい
  printf("%-20s: %.1f[cm], %4.1f[kg], BMI=%.2f\n", *i)
end