Friday, April 19, 2019

Grade Example Score double score

double score = 50;    double maxScore = 100;
    double percent = (score / maxScore) * 100;    String letterGrade = " ";
    if (percent >= 90) {
        letterGrade = "A";
    }else if (percent >= 80) {
        letterGrade = "B";
    }else if (percent >= 70) {
        letterGrade = "C";
    }else if (percent >= 60) {
        letterGrade = "D";    } else {
        letterGrade = "F";    }
    System.out.println("You got a " + letterGrade + " " + percent + "%");    }


    }

Saturday, April 13, 2019

if els statement Java Code | bha

String driveMode = " " ;
       String parkingtype = "Parallel";
       String rearParkingCamera = "OFF";

       if (driveMode.equals("D")) {
           Scanner input = new Scanner(System.in);
           System.out.println("Enter the mode in which you want to drive : Sports,Snow or Regular :");
           String driveType = input.next();
           if (driveType.equals("Snow")) {
               System.out.println("You are driving in Snow Mode");
           }
           if (driveType.equals("Sports")) {
               System.out.println("You are Driving in Sports Mode");
           } else if (driveType.equals("Regular")) {
               System.out.println("You are Driving in Regular Mode");
           } else {
               System.out.println("Drive Safely");
           }
       }else if(driveMode.equals("P")){
           if (parkingtype.equals("Parallel")) {
               System.out.println("Park Parallel between two cars");
           } else {
               System.out.println("Park anywhere");
               }
       }else if(driveMode.equals("R")){
              if (rearParkingCamera.equals("ON")){
                  System.out.println("Rear View Camera is ON");
              } else {
                  System.out.println("Rear View Camera is OFF, be careful while going back");
              }
   }else if(driveMode.equals("N")){
           System.out.println("You are In Neutral Mode,You are getting Car Wash");
       }

    else {
           System.out.println("Invalid Drive Mode");
       }
   }

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");
       }

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");        }

            }
        }

Thursday, April 11, 2019

Java Class 6 | If els method

package array;
public class HomeWorkClass6 {
    public static void main(String[] args) {

// I want to be able to put car on P mode, D mode, N mode, R mode.
//1. If i am on P mode and parking type is parallal i can park between two cars.
//2. if I am on d mode i can put drive type to Snow Type, Sport type or Regular type
//3. If im on N mode i can put car into car wash station
//4. if i am on R mode i can only reverse the car and car will active back camera.
//5. if mode is incorrect print me invilid mode type, please cheek your car mode.
boolean ifDrivingModeon = true;
boolean ifNetralModeon = true;
boolean ifParkModeon = true;
boolean ifReversModon = true;
boolean carOnparallaltype = true;

if (ifParkModeon && carOnparallaltype){
    System.out.println("You Can park the car between two cars");
}else if (ifDrivingModeon){
    System.out.println("You can choice Snow mode, Sports Mode");
}else if (ifNetralModeon){
    System.out.println("You can take the car to the car wash");
}else if (ifReversModon){
    System.out.println("Yor Backup camera is Activited");
}else {
    System.out.println("Invalid mode type Please cheek car mode");}

}
}

Friday, April 5, 2019

Home Work 1 and 2

Home work based on Class 4 Java type, Primitive and non Primitive


* Homework Part 1: Primitive Data Types
         * Create a variable with value and assign appropriate primitive data types
         * 1. Distance between earth & moon
         * 2. Number of keys on a piano
         * 3. Average age of you and your siblings
         * 4. Is your gender male
         * 5. United State debt value
         * 6. Minimum age to purchase Alcohol in US
         *



         * Homework Part 2: String data types
         *  * 1. String myStatment = "I am a good programmer"
         *  * 2. Find the length of of "myStatment"
         *  * 3. Convert all values to lowercase
         *  * 4. See if statment contains mohammad
         *  * 5. find the 5th index of the statement
         *  * 6. find if the statment is empty
         *  * 7. compare the "myStatement" with "technosoft"
         *  * 8. Check if message starts with "Welcome"
         *  * 9. Check if message ends with "Good Bye"

Wednesday, April 3, 2019

public static void main (String[] args)


  • Java only starts running a program with the specific public static void main(String[] args) signature, and one can think of a signature like their own name - it's how Java can tell the difference between someone else's main() and the one true main().

  • String[] args is a collection of Strings, separated by a space, which can be typed into the program on the terminal. More times than not, the beginner isn't going to use this variable, but it's always there just in case.