LoginSignup
1
1

More than 5 years have passed since last update.

Ruby練習問題01

Posted at
Hello,Rubyと表示してください。
puts "Hello, Ruby"
10+4と表示してください。
puts "10+4"
入力された文字列をgets.chompを用いて受け取り、その文字列の文字数と反転した文字列を表示
puts '好きな文字列を入力してください'
x = gets.chomp
puts x.length
puts x.reverse
入力された日数を受け取り、その日数が、何時間、何分、何秒であるかを計算して表示
puts '日数を入力してください'
# getsで受け取った文字列を「to_i」メソッドを用いて
# 数値に変換する
days = gets.chomp.to_i

hours = days * 24
puts "#{hours}時間"

minutes = hours * 60
puts "#{minutes}分"

seconds = minutes * 60
puts "#{seconds}秒"
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1