DEV Community

Discussion on: Daily Challenge #56 - Coffee Shop

Collapse
 
lordapple profile image
LordApple • Edited

I also like it, and decided to rewrite it in c++

    const auto pay = [](float cash){
        const auto coffee = std::unordered_map<float, std::string>{
                {2.2, "Americano"},
                {2.3, "Latte"},
                {2.4, "Flat white"},
                {3.5, "Filter"},

        }[cash];

        return coffee.empty() ? "Sorry, exact change only, try again tomorrow!"
                              : "Here is your " + coffee + ", have a nice day!";
    };