Attempts and rounds


#1

Im stuck finding out how I only let the user guess three times.
Also how I let the user have 10 different rounds, after those rounds it tally sup the score.

heres what I have so far

hidden = rand(1…10)
puts “WELCOME TO THE GUESSING GAME”
puts “GUESS WHAT NUMBER THE COMPUTER IS THINKING!”
game_on = ‘Y’
while (game_on == ‘Y’)
puts "TYPE IN YOUR GUESS: "
guess = 0
until guess == hidden
guess = gets.to_i
if guess == hidden
puts “YOU GOT IT!”
elsif guess < hidden
puts “GUESS HIGHER!”
else
puts “GUESS LOWER!”
end
end
puts “Y OR N”
game_on = gets.chomp
end
if game_on == ‘N’
puts “GOODBYE!”
else puts “YOU DIDNT LISTEN, GOODBYE.”
end


#2

Hello @sdem9,

I suggest you to try to find yourself the answer. For example, check here.

If you are still experiencing any difficulties, please describe them.


#3

okay, well, you don’t have to reply either. In the mean time I am still searching for answers and trying. So, I don’t understand what point you are trying to make (:

but thanks man!

much appropriated for the link.

This place and possibly you are what you would call a “pit stop” and a why not rout.

But thanks again. Once again you don’t have to reply. The assumption I don’t find the answer myself is a motherly thing. Thanks! Cheers!

Once again you don’t have to reply :smiley:


#4

for loop
that’s all that you need.