Skip to content

Instantly share code, notes, and snippets.

@mikestratton
Created May 4, 2015 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikestratton/1ac4f2762cf109010ce3 to your computer and use it in GitHub Desktop.
Save mikestratton/1ac4f2762cf109010ce3 to your computer and use it in GitHub Desktop.
Input student score and outputs grade results with message.
#output grade results dependent on student score
puts "Enter the students score: "
score = gets.to_i
while score > 100
puts "You must enter a number less then or equal to 100 "
puts "Enter the students score: "
score = gets.to_i
end
while score == 100
puts "PERFECT SCORE! FANTASTIC! A score of #{score} gives you a perfect A"
exit
end
while score >= 90 and score <= 99
puts "CONGRATULATIONS! A score of #{score} gives you an A"
exit
end
while score >= 80 and score <= 89
puts "Very good! A score of #{score} gives you a B"
exit
end
while score >= 70 and score <= 79
puts "You can do better. A score of #{score} gives you a C"
exit
end
while score >= 60 and score <= 69
puts "Warning! Be careful. A score of #{score} gives you a D"
exit
end
while score <= 59
puts "FAILURE! You have failed your exam. A score of #{score} gives you an F"
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment