Saturday, April 13, 2019

If els statement Java Code

public class HomeWork7 {
    public static void main(String[] args) {
        /**         * I want to be able to put car on P mode, D mode, N mode, R mode         * If i am on P mode and parking type is parallel then i can park between two cars         * If i am on D mode I can put drive type to Snow type, Sport Type or Regular type         * If i am on N mode i can put car in car wash station         * If i am on R mode I can only reverse the car and car will activate back camera         * If mode is incorrect then print me invalid mode type, please check your car mode         */
//        String nAme = "Mohammad Sohel";//        String lAstName = nAme.substring(nAme.length()-5);//        System.out.println(lAstName);//        String var = "Pea&ce #out f@or all";//        String[] sp = var.split("&");//        System.out.println(Arrays.toString(sp));

        String dRivingMode = "B";        boolean pArallalParkType = true;        boolean rEvierseCam = false;
        if (dRivingMode.equalsIgnoreCase("D")) {
            System.out.println("You are on regular mode");            Scanner input = new Scanner(System.in);            System.out.println("Enter the driving mode which you want to drive : Sports, Snow, Regulr ");            String dRiveType = input.nextLine();            if (dRivingMode.equalsIgnoreCase("Snow")) {
                System.out.println("You are driving on snow mode");            }
             if (dRivingMode.equalsIgnoreCase("Sports")) {
                System.out.println("You are driving on Sports mode, Be aleart");            } else {
                System.out.println("Drive carefully");            }
        } else if (dRivingMode.equalsIgnoreCase("P")) {
            if (pArallalParkType) {
                System.out.println("Park between two cars");            }else {
                System.out.println("Park some other palce");            }
        }else if (dRivingMode.equalsIgnoreCase("R")) {
            if (dRivingMode.equalsIgnoreCase("R") && rEvierseCam) {
                System.out.println("Your back camera is on you can park safely");            }else {
                System.out.println("Camera is off Backup Car safely");            }
        }else if (dRivingMode.equalsIgnoreCase("N")){
            System.out.println("You are ready for carwash");        }else {
            System.out.println("Invalid mode");        }

            }
        }

No comments:

Post a Comment