<repo_name>Dhavalkurkutiya/Java-Tutorial<file_sep>/CWH40AccessMosifireGetterandSetter.java
package com.dhavalkurkutiya;
class MyEmployee{
  // private access modifire
  private int id;
  private String name;
  
  // This mtahid to getName
  public  String getName(){
    return name;
  }  
  
  // This method to setName
  public void setName(String n){
    this.name = n;
  }
  
  // This method to setId
  public void  setId(int i){
    this.id = i;
  }
  
  // This method to getId
  public int getId(){
    return id;
  }
  
}

public class CWH40AccessMosifireGetterandSetter {
  public static void main(String[] args) {
    MyEmployee harry = new MyEmployee();
    // There an eroor throw dou to private access modifire
    /*
    harry.id = 56;
    harry.name = "Dhavalkurkutiya";
    */
    
    //Set tha harry name 
    harry.setName("CodeWithaHarry");
    System.out.println(harry.getName());
    
    //Set a harry id
    harry.setId(56);
    System.out.println(harry.getId());
    
  }
}
<file_sep>/CWH26ArrayinJava.java
package com.dhavalkurkutiya;

public class CWH26ArrayinJava {
  public static void main (String[] args) {
    /*
    Classroom of 500 Students -0 You have to Store Marks these 500 Students
    You have 2 Options:
    1. Create a 500 Virble 
    2. Use Array (recommend)
    */
    
    /*There are there main ways to create an Array in Java*/
    // 1. Declaration and memory allocation
    // int [] Marks = new int[5];
    // 2. Declarationnand and  then  memory allocation
    // int [] Marks;
    // Marks = new int [5];
    // Marks[0] = 00;
    // Marks[1] = 10;
    // Marks[2] = 20;
    // Marks[3] = 30;
    // Marks[4] = 40;
    // System.out.println(Marks[4]);
    
    // 3. Declarationnand , memory allocation and Instantiation to gather 
    int [] Marks = {10,20,30,40,50,60,70,80,90,100};
    System.out.println(Marks[2]);
  }
}
<file_sep>/CWH43JavaExasize3GuessingthaNumber.java
package com.dhavalkurkutiya;

public class CWH43JavaExasize3GuessingthaNumber {

  public static void main(String[] args) {
    System.out.println("Java Exasize Guessing tha Number...");
    /*
     1. Creating a Game Class "Guess tha Number"
     2. Contractors Ganrete a Rendon Number
     3 take UserInput() to take user input
    */
  }
}
<file_sep>/CWH20Exsize2RickSizerPepper.java
package com.dhavalkurkutiya;

public class CWH20Exsize2RickSizerPepper {
public static void main (String[] args) {
  System.out.println("Note code");
}
}
<file_sep>/CWH34Recursioninjava.java
package com.dhavalkurkutiya;

public class CWH34Recursioninjava {
  // factorial(0) = 1
  // factorial(n) = n * n-1 *...1
  // factorial(5) = 5 * 4 * 3 * 2 * 1
  // factorial(n) = n * factorial(n-1)
static int factorial(int n){
  if (n==0 || n==1){
    return 1;
  } 
  else{
   return n*factorial(n-1);
  }
}static int factorial_itartive(int n){
  if (n==0 || n==1){
    return 1;
  } 
  else{
    int product = 1;
    for (int i = 1; i<=n; i++){ // 1 to n
      product *= i;
    } 
    return product;
  }
} 
  public static void main(String[] args) {
    int n = 5;
    System.out.println("Thare factorial "  + n + " is " + factorial(n));
    System.out.println("Thare factorial "  + n + " is " + factorial_itartive(n));
  }

}
<file_sep>/CWH37BasicTerminologyinObjectOrientation.java
package com.dhavalkurkutiya;

public class CWH37BasicTerminologyinObjectOrientation {

  public static void main(String[] args) {

  }
}
<file_sep>/CWH13IntroductionString.java
package com.dhavalkurkutiya;
import java.util.Scanner;
public class CWH13IntroductionString {
  public static void main (String[] args) {
    String name_new = new String("Dhavalkurkutiya");
    String name = "Dhavalkurkutiya";
      
    // %d int 
    // %f float
    // %s String
    // %c char
  
    int a = 6;
    float b = 8.98f;
    // System.out.printf("a = %d and b  = %f \n", a,b);
    // System.out.format("a = %d and b  = %f", a,b);
    
    Scanner sc = new Scanner(System.in);
    String st = sc.next(); // all selcted "sc.nextLine"
    System.out.println(st);
    
    
  }
}
<file_sep>/CWH22dowhile.java
package com.dhavalkurkutiya;

public class CWH22dowhile {
  public static void main (String[] args) {
    int a = 0;
    do{
      System.out.println(a);
      a++;
    }while(a<=80);
  }
}
<file_sep>/CWH41Exasize2Solutions.java
package com.dhavalkurkutiya;

public class CWH41Exasize2Solutions {

  public static void main(String[] args) {

  }
}
<file_sep>/CWH21WhileLoopinJava.java
package com.dhavalkurkutiya;

public class CWH21WhileLoopinJava {
  public static void main(String[] args) {
    int i = 100;
    while (i <= 200) {
      System.out.print(i + "\n");
      i++;
    }
    System.out.println("Finish While Loop");
    while (true) {
      System.out.println("I am Infinet");
      break;
    }
    
  }
}
<file_sep>/CWH25PracticesSet.java
package com.dhavalkurkutiya;

public class CWH25PracticesSet {
  public static void main (String[] args) {
    // Practice Problem 1
    /*
    int n = 10;
    for (int i = n; i>0; i--){
      for (int j = 0; j<i; j++){
      System.out.print("*");
      }
      System.out.print("\n");
    } 
    */
    
    // Practice Problem 2
    /*
    int sum = 0;
    int n = 3;
    for (int i = 0; i<n; i++) {
      sum = sum + (2*i);
    }
    System.out.print("Sum of Even Numbers: ");
    System.out.print(sum);
    */
    
    // PracticemProblem 3
    /*
    int n = 5;
    for (int i = 1; i<=10; i++){
      System.out.printf("%d X %d = %d\n", n, i, n*i);
    }
    */
    // PracticemProblem 4
    /*
    int n = 10;
    for (int i = 10; i>=1; i--){
      System.out.printf("%d X %d = %d\n", n, i, n*i);
    } 
    */
    // PracticemProblem 5
    
    
    // PracticemProblem 6
    
    //What is a Factorial n = n*n-1 * n-2 .....1
    // 5! = 5x4x3x3x1 = 120
    /*
    int n = 5;
    int i =1;
    int Factorial = 1;
    while(i<=n){
      Factorial *= i;
      i++;
    }
    System.out.println(Factorial);
    */
    
    // Practice Problem 9
    int n = 8;
    int sum = 0;
    for (int i = 1; i<=10; i++){
      sum += n*i;
    } 
    System.out.println(sum); 
  }
}
<file_sep>/CWH11ExsizeSolution.java
package com.dhavalkurkutiya;
import java.util.Scanner;

public class CWH11ExsizeSolution {
  public static void main (String[] args) {
  Scanner sc = new Scanner(System.in);
  }
}
<file_sep>/CWH42Constructorsinjava.java
package com.dhavalkurkutiya;

class MyMainEmployee {
  // private access modifire
  private int id;
  private String name;

  // This is Constructor
  public MyMainEmployee() {
    id = 45;
    name = "Your_Name_Hear";
  }

  // This is Constructor
  public MyMainEmployee(String myName, int myId) {
    id = myId;
    name = myName;
  }
  // This is Constructor
  public MyMainEmployee(String myName) {
    id = 5;
    name = myName;
  }
  // This mtahid to getName
  public String getName() {
    return name;
  }

  // This method to setName
  public void setName(String n) {
    this.name = n;
  }

  // This method to setId
  public void setId(int i) {
    this.id = i;
  }

  // This method to getId
  public int getId() {
    return id;
  }
}

public class CWH42Constructorsinjava {

  public static void main(String[] args) {
    // MyMainEmployee harry = new MyMainEmployee("Dhavalkurkutiya",12);
    MyMainEmployee harry = new MyMainEmployee();
    // harry.setName("CodeWithHarry");
    // harry.setId(67);

    System.out.println(harry.getId());
    System.out.println(harry.getName());
  }
}
<file_sep>/CWH27ForEach.java
package com.dhavalkurkutiya;

public class CWH27ForEach {
  public static void main (String[] args) {
  /*
    int [] Marks = {10,20,30,40,50,60,70,80,90,100}; 
    float [] Marks = {10.1f,20.2f,30.3f,40.4f,50.5f,60.6f,70.7f,80.8f,90.9f,100.10f}; 
    System.out.println(Marks.length);
    System.out.println(Marks[1]);
    
    String [] name = {"Dhaval" , "Harry" , "Lovesh"};
    System.out.println(name.length);
    System.out.println(name[0]);
  */
    // Display tha Array (Naive Ways)
  /*  int [] Marks = {10,20,30,40,50}; 
    System.out.println(Marks[0]); 
    System.out.println(Marks[1]); 
    System.out.println(Marks[2]); 
    System.out.println(Marks[3]); 
    System.out.println(Marks[4]);
  */
    // Display tha Array (Fore Loop)
  /*  
  System.out.println("Display Arry Using Fore loop");
  int [] Marks = {10,20,30,40,50,60,70,80,90,100}; 
    for (int i = 0; i<Marks.length;i++){
      System.out.println(Marks[i]);
    }
  */
  
  /*
    // Display tha Array in Reverse order(Fore Loop)
    System.out.println("Display Arry Using Fore loop  in Reverse order");
    int [] Marks = {10,20,30,40,50,60,70,80,90,100}; 
    for (int i = Marks.length -1; i>0;i--){
      System.out.println(Marks[i]);
    }
  */
  
     // Display tha Array (For Each Loop)
    System.out.println("Display Arry Using Fore Each loop");
    int [] Marks = {10,20,30,40,50,60,70,80,90,100}; 
    for(int element : Marks){
      System.out.println(element);
    }
  }
}
<file_sep>/CWH31Mathodsinjava.java
package com.dhavalkurkutiya;

public class CWH31Mathodsinjava {
  static int logic(int x , int y){
    int z;
   if (x > y) {
     z = x + y;
   }
   else{
   z = (x + y) * 5;  
   }
   return z;
  }
  public static void main (String[] args) {
   int  a = 50;
   int b = 7;
   int c ; 
  // Mathod invocation using object Creation
  // CWH31Mathodsinjava obj = new CWH31Mathodsinjava();
   c = logic(a , b);
   System.out.println(c);
   
   int  a1 = 5;
   int b1 = 2;
   int c1 ; 
   
   c1 = logic(a1 , b1);
   System.out.println(c1);
  }
} 
<file_sep>/CWH04Literals.java
package com.dhavalkurkutiya;

public class CWH04Literals {
  public static void main (String[] args) {
    //Literals is right side  value
    byte age_1 = 50;
    int age_2 = 68;
    short sort = 66;
    long log = 6789999999999999L; //Set long numbarb "L" 
    
    char chr = 'A';
    
    float f1 = 6.8f; // set float 
    double d1 = 67.9D; // default doublen "D"
    
    boolean b1 = true;
    
    String str = "This is a java";
    System.out.println(age_2);
  
  }
}
<file_sep>/CWH17Logical.java
package com.dhavalkurkutiya;

public class CWH17Logical {
public static void main (String[] args) {
    System.out.println("For Logical AND [&&] ...");
    boolean a = true;
    boolean b = true;
    boolean c = true;
    if (a && b && c){
      System.out.println("Y");
    }
    else{
      System.out.println("N");
    }
    
    System.out.println("For Logical Or [||]...");
    boolean a1 = true;
    boolean b2 = false;
    boolean c3 = true;
    if (a|| b){
      System.out.println("Y");
    }
    else{
      System.out.println("N");
    }
    
   System.out.println("For Logical Not [!]...");
   System.out.print("Not (a) is ");
   System.out.println(!a);
   
   System.out.print("Not (b) is ");
   System.out.println(!b);
   
  }
}
<file_sep>/CWH06CBSE.java
package com.dhavalkurkutiya;
import java.util.Scanner;

public class CWH06CBSE {
  public static void main (String[] args) {
    Scanner sc = new Scanner (System.in);
    
    // System.out.println("Total Marks is 300");
    
    System.out.println("Mathematics");
    float Mathematics = sc.nextFloat();
    
    System.out.println("Chemistry");
    float Chemistry = sc.nextFloat();
    
    System.out.println("Physics");
    float Physics = sc.nextFloat();
    
    float sum = Mathematics + Chemistry + Physics;
    System.out.println(sum/3 + " %");
  }

}
<file_sep>/CWH18SwitchStament.java
package com.dhavalkurkutiya;
import java.util.Scanner;

public class CWH18SwitchStament {
public static void main (String[] args) {
    int age;
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter your age:");
    age = sc.nextInt();
    
    switch(age) {
      case 18:
        System.out.println("You are Education");
        break;
        
      case 30:
        System.out.println("You are job aply");
        break;
        
      case 60:
        System.out.println("You are job Retaryerd");
        break;
        
      default:
        System.out.println("You are Enjoy Life");
    }
    
    /*
    if (age>56){
      System.out.println("You are Expected");
    } 
    else if (age>45) {
      System.out.println("You are Noob");
    }
    else if (age>30) {
      System.out.println("You are Noob");
    }
    else{
      System.out.println("You are grat");
    }
    */
  }
}
<file_sep>/CWH16Conditionals.java
package com.dhavalkurkutiya;

public class CWH16Conditionals {
public static void main (String[] args) {
    int age = 18;
    if (age!=18){
      System.out.println("Yas You can drive");
    }
    else{
      System.out.println("Not You can drive");
    }
  }
}
<file_sep>/CWH32Mathadoverloadinginjava.java
package com.dhavalkurkutiya;

public class CWH32Mathadoverloadinginjava {
  static void foo(){
    System.out.println("Good Morning !");
  }
  static void foo(int a){
    System.out.println("Good morning ! " + a + " Bro");
  }
  static void foo(int a , int b){ //(int a , int b) Perametter
    System.out.println("Good morning ! " + a + " Bro");
    System.out.println("Good morning ! " + b + " Bro");
  }


  static void chang1(int a) {
    a = 98;
  }

  static void chang2(int[] arry) {
    arry[0] = 70;
  }

  static void tailJocks() {
    System.out.println("Hay I am Dhavalkurkutiya");
  }

  public static void main(String[] args) {
    /* Case:1 Changing Tha Integer */

    tailJocks();
    // int x = 45; // Can't Chang valu of [X]
    // chang1(x);
    // System.out.println("Tha value is x after runing tha chang = " + x);

    /* Case:2 Changing Tha Array */
    // int[] marks = {56, 88, 98, 88, 78}; // Chang this value only refrance pass  
    // chang2(marks);
    // System.out.println("Tha value is chang2 after runing tha chang2 = " + marks[0]);
    
    
    /* Mathadoverloading */
    //foo();
   // foo(a , 333);
    //foo(a , 300 , b ,500); //Argument
  }
}
