ある年のある月の日数を求めるメソッドを作りたいです。
以下のコードが実行されません。。
どこが悪いのでしょうか。。。
def
get_days(year,month)
month days = [31,28,31,30,31,30,31,31,30,31,30,31]
return month_days[month - 1]
end
puts"年を入力してください"
year = gets.to_i
puts"月を入力してください"
month = gets.to_i
days = get_days(year,month)
puts"#{year}年#{month}月は#{days}日間あります"
回答4件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/10/05 08:25