Course of Raku / Advanced / More about built-in types / Enumerations 🆕 / Exercises

Count and total

Problem

Define an enum Coin whose constants carry their value in cents: penny is 1, nickel is 5, dime is 10, and quarter is 25. Using .enums, print how many constants the enum has, and then print the total of all their values.

Example

The program prints:

4
41

Solution

See the solution

Course navigation

Solution: Weekday numbers   |   Solution: Count and total