Ask Question
17 July, 15:40

Simulate a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the light can be on or off. Toggling either switch turns the lamp on or off. Provide member functions.

+1
Answers (1)
  1. 17 July, 16:40
    0
    int switch_1, switch_2;

    int get_first_switch_state ()

    {

    return switch_1;

    }

    int get_second_switch_state ()

    {

    return switch_1;

    }

    int get_lamp_state ()

    {

    if ((get_first_switch_state ())

    if (get_second_switch_state ()) return 1;

    else

    if (! get_second_switch_state ()) return 1;

    return 0;

    }

    void toggle_first_switch ()

    {

    if (get_first_switch_state ()) switch_1=0;

    else switch_1=1;

    }

    void toggle_second_switch ()

    {

    if (get_second_switch_state ()) switch_2=0;

    else switch_2=1;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Simulate a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers