Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ruby 値に名前つける練習

Last updated at Posted at 2023-06-07

ゴルフのスコアが1日目120、二日目が100、三日目が80だった場合のゴルフスコアの平均点をターミナルに出力するプログラムを記す。

出力結果は、

3日間のゴルフスコアの平均点は、◯点です。
 
というようにしたい。

条件:各日の点数を変数を使って定義。

day_1=120
day_2=100
day_3=80

average_score=(day_1+day_2+day_3) / 3

puts "3日間のゴルフスコアの平均点は、#{average_score}点です。"

読みやすいコードを書くことを意識しよう。

1
2
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?