Course of Raku / Objects, I/O, and exceptions / Classes and objects / Methods / Exercises

Temperature conversion

Problem

Define a class Celsius with an attribute degrees, and a method to-fahrenheit that converts the temperature to Fahrenheit with the formula degrees × 9 / 5 + 32.

Create a Celsius object for 100 degrees, and print its Fahrenheit value.

Example

The program prints:

212

Solution

See the solution

Course navigation

Solution: Rectangle area   |   Solution: Temperature conversion