Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I don't know what i'm suppose to do!!! Please Help!!! import java.util.Scanner; /** * Simulate minivan sliding door control software. * * This is a
I don't know what i'm suppose to do!!! Please Help!!! import java.util.Scanner; /** * Simulate minivan sliding door control software. * * This is a solution for Programming Exercise P3.38 */ public class MinivanSlidingDoors { public static void main(String[] args) { final String GEAR_SHIFT_VALUES = "PND123R"; Scanner inp = new Scanner(System.in); System.out.print("Dashboard Switch Left Door: "); int dbsLeftDoor = inp.nextInt(); if(dbsLeftDoor != 0) dbsLeftDoor = 1; System.out.print("Dashboard Switch Right Door: "); int dbsRightDoor = inp.nextInt(); if(dbsRightDoor != 0) dbsRightDoor = 1; System.out.print("Dashboard Switch Child Lock: "); int dbsChildLock = inp.nextInt(); if(dbsChildLock != 0) dbsChildLock = 1; System.out.print("Dashboard Switch Master Unlock: "); int dbsMasterUnlock = inp.nextInt(); if(dbsMasterUnlock != 0) dbsMasterUnlock = 1; System.out.print("Inside Handle Left Door: "); int ishLeftDoor = inp.nextInt(); if(ishLeftDoor != 0) ishLeftDoor = 1; System.out.print("Inside Handle Right Door: "); int ishRightDoor = inp.nextInt(); if(ishRightDoor != 0) ishRightDoor = 1; System.out.print("Outside Handle Left Door: "); int oshLeftDoor = inp.nextInt(); if(oshLeftDoor != 0) oshLeftDoor = 1; System.out.print("Outside Handle Right Door: "); int oshRightDoor = inp.nextInt(); if(oshRightDoor != 0) oshRightDoor = 1; System.out.print("Gear Shift: "); String gearShift = inp.next(); gearShift = gearShift.toUpperCase(); if(gearShift.length() != 1 || GEAR_SHIFT_VALUES.indexOf(gearShift) == -1) { System.out.println("Gear Shift must be in " + GEAR_SHIFT_VALUES); return; } System.out.println(); System.out.println("Switch State"); System.out.println("Dashboard Switch Left Door: " + dbsLeftDoor); System.out.println("Dashboard Switch Right Door: " + dbsRightDoor); System.out.println("Dashboard Switch Child Lock: "); System.out.println("Dashboard Switch Master Unlock: " + dbsMasterUnlock); System.out.println("Inside Handle Left Door: " + ishLeftDoor); System.out.println("Inside Handle Right Door: " + ishRightDoor); System.out.println("Outside Handle Left Door: " + oshLeftDoor); System.out.println("Outside Handle Right Door: " + oshRightDoor); System.out.println("Gear Shift: " + gearShift); System.out.println(); boolean leftDoorOpen = false; boolean rightDoorOpen = false; if("P".equals(gearShift) && dbsMasterUnlock == 1) { if(dbsLeftDoor == 1 || oshLeftDoor == 1 || (dbsChildLock == 0 && ishLeftDoor == 1)) { leftDoorOpen = true; } if(dbsRightDoor == 1 || oshRightDoor == 1 || (dbsChildLock == 0 && ishRightDoor == 1)) { rightDoorOpen = true; } } boolean doorOpen = leftDoorOpen || rightDoorOpen; if(doorOpen) { if(leftDoorOpen) { System.out.println("left door opens"); } if(rightDoorOpen) { System.out.println("right door opens"); } } else { System.out.println("both doors stay closed"); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started