From: James Edward Gray II Date: 2006-02-28T12:44:07+09:00 Subject: Re: Pine's book "Learning to Program" - Answer? On Feb 27, 2006, at 9:33 PM, woodyee wrote: > Hi! I'm stuck on Chapter 5, 5.4: > > "Write a program which asks for a person's favorite number. Have your > program add one to the number, then suggest the result as a bigger and > better favorite number. (Do be tactful about it, though.)". > > Any ideas? I'm getting "can't convert fixnum into string" errors. > Here's one of the many things I've tried, er, failed: > > puts 'What is your favorite number ?' > num = gets.chomp > better = 'num'.to_i + 1 There's your problem line. 'num' is a String of the letters n, u, and m. num is the variable holding the number. Drop the quotes here. > puts 'This is better: ' + better + '.' This line will be another problem. better will hold an Integer, but you want a String here. Try better.to_s instead. > 3rd line's getting me. Can't figure out how to add 1 to the response. > Hopefully, I'll figure this out but any tips are welcomed. Thanks! Hope that helps. Welcome to Ruby! James Edward Gray II