New to coding and not sure what I'm doing wrong here. this is what I have so far:
put "Enter degrees in Celsius:"
Celsius = gets.chomp
def celsius_to_fahrenheit (c)
fahrenheit = (c * 9/5)+32
end
puts "The temperature is #{celsius_to_farenheit (Celsius)} in Farenheit"
Here it is fixed:
celsius_to_farenheitput(should beputs)cwas a String, not an int / float. Can't do math on a StringOverall, your biggest mistake is not reading your error logs. When you run the program, it'll output errors indicating your mistakes. One by one, you should fix the errors until your program compiles/runs. Don't just randomly fix the errors. Read the message, think about what you did and what you're trying to do, then fix the error.
That means you're attempting to call a function (the erroneous put function) at the top of the file.
Same symptom, different disease.
See how it tells me everything I need to know?
I converted that "c" value to a float. By default, a user's input should be interpreted as a String. You have to "cast" (convert) the variable to a float if you want the user's input to be interpreted as a float and not a string.
The reason you see
666666666is because Ruby tries to be fancy. If you multiply a string by an int, N, you get that string repeated N times.eg.
"hello world" * 2 # hello worldhello world