While I really don't get what I need here, one thing that immediately jumped in my opinion is the block:
option = gets()
if option == 1
then
puts "AccelCalc"
else
puts "EnergyCalc"
end
getsreturns a string. So you should do:
case gets().strip()
when "1"
puts "AccelCalc"
when "2"
puts "EnergyCalc"
else
puts "Invalid input."
end
Here I used explicit brackets, instead gets().strip()you can just write gets.stripin Ruby. What this expression does is read something from standard input and removes all spaces around it (newline from pressing the enter key). Then the resulting string is compared.
source
share