Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your typical modern minivan has two sliding doors. And are also crazy automated.

ID: 3649143 • Letter: Y

Question

Your typical modern minivan has two sliding doors. And are also crazy automated. These doors will auto-open if you pull the handle inside, the handle outside, or press a switch on the dashboard. However, the inside handles do not work if the child lock is engaged. Also, for the doors to open, the van has to be in park and the master unlock switch must be activated.

Write a program called MinivanDoors.java that simulates what happens in the various situations when trying to open or close the doors to the minivan. Assume that both the doors start in the closed position.

INPUT: a single line of values, such as in the form 0 0 0 1 0 1 0 0 P, where the items are in the order (left door dashboard switch, right door dashboard switch, child lock, master unlock, inside left handle, inside right handle, outside left handle, outside right handle, gear shift setting (one of P N D R 1 2 3)) and 0 indicates off/not activated and 1 indicates on/activated.

OUTPUT: Only one of four outputs should appear: "Left door opens," "Right door opens," "Both doors open," "Both doors stay closed."

please use Java only. No other languages. Use only if and if else statements ,Scanner,String... Do not use WHILE or FOR please . That is how the asignment should be done. thanks

Here are some examples

Please enter the current minivan state: 0 0 1 1 1 1 0 0 R
Both doors stay closed.

Please enter the current minivan state: 1 0 0 1 0 0 0 0 P
Left door opens.

Please enter the current minivan state: 0 0 0 1 0 1 0 0 P
Right door opens.

Please enter the current minivan state: 0 0 0 1 0 0 1 1 P
Both doors open.

Explanation / Answer

please rate - thanks

import java.util.*;
public class MinivanDoors
{public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int left,right,child,master,inleft,inright,outleft,outright;
String gear;
System.out.print("Please enter the current minivan state: ");
left=in.nextInt();
right=in.nextInt();
child=in.nextInt();
master=in.nextInt();
inleft=in.nextInt();
inright=in.nextInt();
outleft=in.nextInt();
outright=in.nextInt();
gear=in.next();
if(gear.equals("P")&&master==1&&child==0)
   {if(left==1||inleft==1||outleft==1)
         {if(right==1||inright==1||outright==1)
              System.out.println("Both doors open.");
            else
                System.out.println("Left door opens.");
         }
    else
          if(right==1||inright==1||outright==1)
              System.out.println("Right door opens.");

   
    }
else
    System.out.println("Both doors stay closed.");               
}
}