Hi I am going the self taught route on learning ruby. I have a question
and hope that this is the right place to ask questions.
My question is:
How do I get a while statement to terminate? I know I can use an if
conditional with break to get out of a while statement. But what I want
to do is to be able to add float numbers without being asked each time
if I want to quit. I would like to just add numbers and when I am done
I will type the string “no”.
I can do this if I use floating numbers/integers but not able to find a
way to do this with a string.
while score >= 0
grades.push score puts "Enter another grade from 1.0 to 100.0 or 0 to quit! " score = gets.to_f
the programme will quit once a value less than zero has been entered. I
would like to be able to do this with a string. If this requires a
nested while loop that would be fine.