question archive • A lamp outside a front door comes on automatically when it is dark, and someone stands on the doormat outside the front door
Subject:Computer SciencePrice:2.87 Bought7
• A lamp outside a front door comes on automatically when it is dark, and someone stands on the doormat outside the front door. • A pressure sensor under the mat changes from OFF (0) to ON (1) when someone stands on the doormat. • The light sensor is ON (1) when it is light and OFF (0) when it is dark. • Design a program to show what would happen to the lamp. Account for all possible scenarios by determining whether the pressure sensor and light sensor are ON or OFF. (HINT: Ask the user “Is it dark?” and “Is someone standing on the doormat outside the front door?”)
Answer:
Download File :
https://drive.google.com/open?id=1IA-Vc8NjKzyjqOQoDhNQj0OUKON0fJ5r
Code converted to c++:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
?? standing;
?? dark;
raptor_prompt_variable_zzyz ="Is it dark?";
cout << raptor_prompt_variable_zzyz << endl;
cin >> DARK;
if (DARK=="Yes")
{
raptor_prompt_variable_zzyz ="Is someone standing on the doormat outside the front door?";
cout << raptor_prompt_variable_zzyz << endl;
cin >> STANDING;
if (STANDING=="Yes")
{
cout << "LAMP IS ON" << endl; }
else
{
cout << "LAMP IS OFF" << endl; }
}
else
{
cout << "LAMP IS OFF" << endl; }
return 0;
}
Output:
PFA