Answer to Question #180450 in C++ for Mridul

Question #180450

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 left and right sliding doors (0 or 1) • The gear shift setting (one of P N D 1 2 3 R). A typical input would be 0 0 0 1 0 1 0 0 P. Print ”left door opens” and/or ”right door Opens” as appropriate. If neither door opens, print ”both doors are closed”. 


1
Expert's answer
2021-04-11T22:42:29-0400
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;
						}
			}
		}
		
	}
	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS