// © Copyrights 2026 Praajna Pattada

#include <iostream>
#include <string>
#include <limits>

enum Switch {
    off, /* 0 */
    on, /* 1 */
};

std::string_view getStatus(Switch exampleSwitch)
{
    switch(exampleSwitch)
    {
        case off: return "off";
        case on: return "on";
        default: return "error";
    }
}

int main()
{
    std::cout << "Enter the state of a switch (0 for off, 1 for on): ";
    int switchState {};
    std::cin >> switchState;
    if (switchState < 0 || switchState > 1)
    {
        std::cout << "Error! You have entered an invalid input." << '\n';
    } else {
        Switch mySwitch { static_cast<Switch>(switchState) };
        std::cout << "The switch is " << getStatus(mySwitch) << '\n';
    }

    std::cin.clear();
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    std::cin.get();
    return 0;
}
