LoginSignup
3
1

More than 1 year has passed since last update.

[Ruby]スコア判定のプログラム

Posted at

はじめに

最近RailsやReactでWebアプリケーションを作ることが多く、「基礎勉強最近してなくね?」と思ったのでその勉強記録として、残しておきます。

問題

80点以上の時にA判定を、40点以上80未満の場合B判定を、40点未満の場合C判定を出すプログラムを書きなさい

解答

def evaluate_grades(score)
  if score >= 80
    p "A判定です"
  elsif score >= 40
    p "B判定です"
  else
    p "C判定です"
  end
end

evaluate_grades(45)
=> "B判定です"

久しぶりに基礎勉強したが意外と楽しいなと感じたのでこれからも取り組み続けてプログラミング力をつけていきたいなと感じた。

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