Instructions
Create a function ctof that converts Celsius to Fahrenheit.
The formula is: F = C * 9/5 + 32
Hints:
- Use the formula: celsius * 9.0 / 5.0 + 32
- This is the inverse of the ftoc function
Your Code
def ctof(celsius) celsius * 9.0 / 5.0 + 32 end
RSpec.describe "ctof" do
it "converts freezing point" do
expect(ctof(0)).to eq(32)
end
it "converts boiling point" do
expect(ctof(100)).to eq(212)
end
it "converts body temperature" do
expect(ctof(37)).to be_within(0.1).of(98.6)
end
end
Results
Click "Run Tests" to see results