Can someone please help me with this, it\'s homework for C++. I have no idea how
ID: 669009 • Letter: C
Question
Can someone please help me with this, it's homework for C++. I have no idea how to do it.
A minivan has two sliding doors. Each door can be opened by either a dashboard switch, its inside handle, or its outside handle. However, the inside handles do not work if a child lock switch is activated. In order for the sliding doors to open, the gear shift must be in park, and the master unlock switch must be activated.
Your task is to simulate a portion of the control software for the vehicle. The input is a sequence of values for the switches and the gear shift, in the following order:
Dashboard switches for left and right sliding door, child lock, and master unlock (0 for off or 1 for activated)
Inside and outside handles on the left and right sliding doors (0 or 1)
The gear shift setting (one of P N D 1 2 3 R).
SAMPLE INPUT:
0 0 0 1 0 1 0 0 P
Dashboard switch on the left door
Dashboard switch on the right door
Child lock
Master unlock
Inside left door latch
Outside left door latch
Inside right door latch
Outside right door latch
Gearshift (P N D 1 2 3 R)
Explanation / Answer
#include<iostream.h>
using namespace std;
int main()
{
bool dashboard_switch_left, dashboard_switch_right, child_lock, left_inside_handle,
left_outside_handle, right_inside_handle, right_outside_handle, master_lock, gear;
cout << "Enter value for left dashboard switch (1=activated, 0=off): " << endl;
cin >> dashboard_switch_left;
cout << "Enter value for the right dashboard switch (1=activated, 0=off): " << endl;
cin >> dashboard_switch_right;
cout << "Enter value for Child Lock (1=activated, 0=off): " << endl;
cin >> child_lock;
cout << "Enter value for inside left handle (1=activated, 0=ff): " << endl;
cin >> left_inside_handle;
cout << "Enter value for outside left handle (1=activated, 0=ff): " << endl;
cin >> left_outside_handle;
cout << "Enter value for inside right handle (1=activated, 0=ff): " << endl;
cin >> right_inside_handle;
cout << "Enter value for outside right handle (1=activated, 0=ff): " << endl;
cin >> right_outside_handle;
cout << "Enter value for Master Lock (1=activated, 0=off): " << endl;
cin >> master_lock;
cout << "Enter value for gear (P=1, N,D,1,2,3,R=0): " << endl;
cin >> gear;
if (master_lock==0)
{
if (child_lock==0)
{
if (gear==1)
{
if (dashboard_switch_left==0) {}
if (left_inside_handle==0) {}
if (left_outside_handle==0)
{
cout << "Left door opens" << endl;
}
}
}
}
else
cout<<"Door remains closed."<<endl;
system("pause");
return 0;
}