Here we are repeatedly taking input from a user inside a while loop.
An if condition tests whether the user enters "q".
The code used chomp() to remove the carriage return from the input.
If "q" is not entered, the first elsif condition tests whether the integer value of the input (input.to_i) is greater than 800.
If this test fails, the next elsif condition tests whether it is less than or equal to 800:
input = "" while input != 'q' do puts("Enter a number between 1 and 1000 (or 'q' to quit)") print("?- ") input = gets().chomp() # from w ww .ja va 2 s . com if input == 'q' puts( "Bye" ) elsif input.to_i > 800 puts( "That's a high rate of pay!" ) elsif input.to_i <= 800 puts( "We can afford that" ) end end