As a rookie to programming, i'm really excited about finishing my first program.
But I know I only learn by making mistakes and through constructive criticism.
I'm open to any feedback regarding my use of branching, and any way to "clean up" my code.
puts 'Hi! Pick a number between 0 and 10'
number = gets.chomp
puts 'Got it; your number is ' + number.to_s + ', right?'
check1 = gets.chomp
if
check1 == 'yes'
puts 'awesome. now double your number. What\'s your new number?'
else
puts 'Oops. Either: A. I oopsie-daisied up or B. you\'re lying.'
end
number_doubled = gets.chomp
if
number_doubled.to_i == number.to_i * 2
puts 'cool. Now add 6. What\'s the new number?'
else
puts 'Oopsie-daisies'
end
number_plus_6 = gets.chomp
if
number_plus_6.to_i == number.to_i * 2 + 6
puts 'cool; Now divide your new answer by 2; What\'s your new number?'
else
puts 'Oopsie-daisies'
end
number_halved = gets.chomp
if
number_halved.to_i == number_plus_6.to_i / 2
puts 'cool. Now, if you subtract the number you originally picked, ' + number + ', you\'re answer will be 3. Is it?'
else
puts 'Oopsie-daisies'
end
check2 = gets.chomp
if
check2 == 'yes'
puts 'See? I told you i was a smarty!!'
else
puts 'hmm, i think you\'re bad at math'
end