Saturday, April 13, 2019

if els Statement Java code | S

boolean isParallelParkingAvailable = false;
       String carMode = "r";
       String driveType = "snow";

       if (carMode.equalsIgnoreCase("p")) {
           if (isParallelParkingAvailable) {
               System.out.println("Park in parallel space");
           } else {
               System.out.println("Parallel parking is not available");
           }
       } else if (carMode.equalsIgnoreCase("d")) {
           if (driveType.equalsIgnoreCase("snow")) {
               System.out.println("We should be able to drive in snow type");
           } else if (driveType.equalsIgnoreCase("sport type")) {
               System.out.println("We should be able to drive in sport type");
           } else if (driveType.equalsIgnoreCase("regular type")) {
               System.out.println("We should be able to drive in regular type");
           } else if (driveType.equalsIgnoreCase("n")) {
               System.out.println("Car can be put in a car wash station");
           } else if (driveType.equalsIgnoreCase("r")) {
               System.out.println("Car can only reverse the car and car will activate back camera");
           }
       }else {
           System.out.println("please check your car mode");
       }

No comments:

Post a Comment