Conversation
CalculatorWhat We're Looking For
Hello Dionisia! Oh no! Your code didn't run when I looked at it. On running this code as is, it looks for a method Let's say that I change line 26 to user_entry = gets.chomp.downcaseWith this change, it doesn't check if the operator is valid, but it'll at least move forward. Then, the code gets stuck -- no matter what input you give it for the numbers, it will always believe that your input is not a number and print Well, the problem is in how you validate the number... you validate the number by calling the method By removing the call to Good work -- next time check that your code runs before submitting ;) |
| when "divide", "/" | ||
| div_total = num1 / num2 | ||
| puts "#{num1} / #{num2} = #{div_total}" | ||
| end |
There was a problem hiding this comment.
I'm being nitpicky, but this end should be on the same indentation as case (so, one less indentation). not a big deal, just a small note!
|
|
||
| # Verifying valid operators have been selected | ||
| def valid_num(number) | ||
| until (true if Float(number) rescue false) |
There was a problem hiding this comment.
In general, this reads kind of funny. Also, number will always be a float, since you get number from the call gets.chomp.to_f, which converts them to floats all the time.
Overall, the code works, but is just a little funny -- I wouldn't call this a high priority thing to correct, but something to return to in a few days or weeks with fresh eyes.
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions