diff --git a/App.java b/App.java new file mode 100644 index 0000000..0a839f9 --- /dev/null +++ b/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} diff --git a/Beginning.java b/Beginning.java new file mode 100644 index 0000000..d6f9465 --- /dev/null +++ b/Beginning.java @@ -0,0 +1,5 @@ +public class Beginning{ + public static void main(String[] args){ + System.out.println("Iam Sabbir Hasanat"); + } +} \ No newline at end of file diff --git a/VS Code/App.class b/VS Code/App.class new file mode 100644 index 0000000..58ec3ed Binary files /dev/null and b/VS Code/App.class differ diff --git a/VS Code/Beginning.class b/VS Code/Beginning.class new file mode 100644 index 0000000..02f766b Binary files /dev/null and b/VS Code/Beginning.class differ diff --git a/VS Code/bin b/VS Code/bin new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/VS Code/bin @@ -0,0 +1 @@ + diff --git a/VS Code/point.class b/VS Code/point.class new file mode 100644 index 0000000..b180986 Binary files /dev/null and b/VS Code/point.class differ diff --git a/VS Code/v21__Constants.class b/VS Code/v21__Constants.class new file mode 100644 index 0000000..7c0e657 Binary files /dev/null and b/VS Code/v21__Constants.class differ diff --git a/VS Code/v26__Integer_Data_Types.class b/VS Code/v26__Integer_Data_Types.class new file mode 100644 index 0000000..9a79db6 Binary files /dev/null and b/VS Code/v26__Integer_Data_Types.class differ diff --git a/VS Code/v27__Get_Integer_Values.class b/VS Code/v27__Get_Integer_Values.class new file mode 100644 index 0000000..2fbd6b5 Binary files /dev/null and b/VS Code/v27__Get_Integer_Values.class differ diff --git a/VS Code/v28__double_data_type.class b/VS Code/v28__double_data_type.class new file mode 100644 index 0000000..78a4cf7 Binary files /dev/null and b/VS Code/v28__double_data_type.class differ diff --git a/VS Code/v29__char_data_type.class b/VS Code/v29__char_data_type.class new file mode 100644 index 0000000..243038a Binary files /dev/null and b/VS Code/v29__char_data_type.class differ diff --git a/VS Code/v30_1.class b/VS Code/v30_1.class new file mode 100644 index 0000000..438dc8a Binary files /dev/null and b/VS Code/v30_1.class differ diff --git a/VS Code/v30__boolean_data_type.class b/VS Code/v30__boolean_data_type.class new file mode 100644 index 0000000..a901134 Binary files /dev/null and b/VS Code/v30__boolean_data_type.class differ diff --git a/VS Code/v31__string_data_type__string_start.class b/VS Code/v31__string_data_type__string_start.class new file mode 100644 index 0000000..b224961 Binary files /dev/null and b/VS Code/v31__string_data_type__string_start.class differ diff --git a/VS Code/v32.class b/VS Code/v32.class new file mode 100644 index 0000000..98cd895 Binary files /dev/null and b/VS Code/v32.class differ diff --git a/VS Code/v33__concatenation.class b/VS Code/v33__concatenation.class new file mode 100644 index 0000000..f67ad75 Binary files /dev/null and b/VS Code/v33__concatenation.class differ diff --git a/VS Code/v35__string_object_create.class b/VS Code/v35__string_object_create.class new file mode 100644 index 0000000..b33f0c8 Binary files /dev/null and b/VS Code/v35__string_object_create.class differ diff --git a/VS Code/v38__taking_input.class b/VS Code/v38__taking_input.class new file mode 100644 index 0000000..8ab22e6 Binary files /dev/null and b/VS Code/v38__taking_input.class differ diff --git a/VS Code/v51.class b/VS Code/v51.class new file mode 100644 index 0000000..7c63959 Binary files /dev/null and b/VS Code/v51.class differ diff --git a/VS Code/v55.class b/VS Code/v55.class new file mode 100644 index 0000000..b2a85d3 Binary files /dev/null and b/VS Code/v55.class differ diff --git a/VS Code/v58.class b/VS Code/v58.class new file mode 100644 index 0000000..697ce4d Binary files /dev/null and b/VS Code/v58.class differ diff --git a/VS Code/v60__Loop_start.class b/VS Code/v60__Loop_start.class new file mode 100644 index 0000000..e5ab811 Binary files /dev/null and b/VS Code/v60__Loop_start.class differ diff --git a/VS Code/v61.class b/VS Code/v61.class new file mode 100644 index 0000000..984972b Binary files /dev/null and b/VS Code/v61.class differ diff --git a/VS Code/v67.class b/VS Code/v67.class new file mode 100644 index 0000000..4341c6e Binary files /dev/null and b/VS Code/v67.class differ diff --git a/VS Code/v68.class b/VS Code/v68.class new file mode 100644 index 0000000..c05975e Binary files /dev/null and b/VS Code/v68.class differ diff --git a/VS Code/v68_1.class b/VS Code/v68_1.class new file mode 100644 index 0000000..4e7daed Binary files /dev/null and b/VS Code/v68_1.class differ diff --git a/VS Code/v68_1__prime_numbers.class b/VS Code/v68_1__prime_numbers.class new file mode 100644 index 0000000..e326455 Binary files /dev/null and b/VS Code/v68_1__prime_numbers.class differ diff --git a/VS Code/v69__Loop_finished.class b/VS Code/v69__Loop_finished.class new file mode 100644 index 0000000..b07e1a0 Binary files /dev/null and b/VS Code/v69__Loop_finished.class differ diff --git a/VS Code/v82.class b/VS Code/v82.class new file mode 100644 index 0000000..fd62be3 Binary files /dev/null and b/VS Code/v82.class differ diff --git a/VS Code/v84.class b/VS Code/v84.class new file mode 100644 index 0000000..034e34a Binary files /dev/null and b/VS Code/v84.class differ diff --git a/VS Code/v85.class b/VS Code/v85.class new file mode 100644 index 0000000..c7b8043 Binary files /dev/null and b/VS Code/v85.class differ diff --git a/VS Code/v86___array_start.class b/VS Code/v86___array_start.class new file mode 100644 index 0000000..f3a8fd3 Binary files /dev/null and b/VS Code/v86___array_start.class differ diff --git a/VS Code/v87.class b/VS Code/v87.class new file mode 100644 index 0000000..5fed863 Binary files /dev/null and b/VS Code/v87.class differ diff --git a/VS Code/v87_1.class b/VS Code/v87_1.class new file mode 100644 index 0000000..eb5d02d Binary files /dev/null and b/VS Code/v87_1.class differ diff --git a/VS Code/v94.class b/VS Code/v94.class new file mode 100644 index 0000000..6c991a4 Binary files /dev/null and b/VS Code/v94.class differ diff --git a/point.java b/point.java new file mode 100644 index 0000000..dcce9b2 --- /dev/null +++ b/point.java @@ -0,0 +1,7 @@ + +public class point { + + public int x; + public int y; + +} diff --git a/v21__Constants.java b/v21__Constants.java new file mode 100644 index 0000000..6b0d94a --- /dev/null +++ b/v21__Constants.java @@ -0,0 +1,8 @@ +public class v21__Constants { + public static void main(String[] args) { + final String My_Name; + My_Name = "Sabbir Hasanat"; + System.out.println(My_Name); + + } +} diff --git a/v26__Integer_Data_Types.java b/v26__Integer_Data_Types.java new file mode 100644 index 0000000..cfc4464 --- /dev/null +++ b/v26__Integer_Data_Types.java @@ -0,0 +1,26 @@ +public class v26__Integer_Data_Types { + public static void main(String[] args) { + + byte b1 = -128; // -128, 127 + short s1 = 20; + int i1 = 100; + long l1 = 999L; + + System.out.println("\n"+b1); + System.out.println(s1); + System.out.println(i1); + System.out.println(l1); + + System.out.println(); + + System.out.println(b1-i1); + System.out.println(s1-b1); + System.out.println(i1-l1); + + System.out.println(); + + l1 = i1; + System.out.println(i1); + System.out.println(l1); + } +} diff --git a/v27__Get_Integer_Values.java b/v27__Get_Integer_Values.java new file mode 100644 index 0000000..8a95002 --- /dev/null +++ b/v27__Get_Integer_Values.java @@ -0,0 +1,9 @@ +public class v27__Get_Integer_Values { + public static void main(String[] args) { + + System.out.println(Integer.MAX_VALUE); + System.out.println(Short.MIN_VALUE); + System.out.println(Byte.MAX_VALUE); + System.out.println(Long.MAX_VALUE); + } +} diff --git a/v28__double_data_type.java b/v28__double_data_type.java new file mode 100644 index 0000000..6c7bf3d --- /dev/null +++ b/v28__double_data_type.java @@ -0,0 +1,7 @@ +public class v28__double_data_type { + public static void main(String[] args) { + + double d = 10; + System.out.println( d - 2.1 ); + } +} diff --git a/v29__char_data_type.java b/v29__char_data_type.java new file mode 100644 index 0000000..6cb70ab --- /dev/null +++ b/v29__char_data_type.java @@ -0,0 +1,19 @@ +public class v29__char_data_type { + public static void main(String[] args) { + char c1 = 'A'; + char c2 = 65; + char c3 = '\u0041'; + + System.out.println(c1); + System.out.println(c2); + System.out.println(c3); + + System.out.println(); + + int code1 = 'A'; + int code2 = '\u0041'; + System.out.println(code1); + System.out.println(code2); + + } +} diff --git a/v30_1.java b/v30_1.java new file mode 100644 index 0000000..53ecbea --- /dev/null +++ b/v30_1.java @@ -0,0 +1,8 @@ +public class v30_1 { + public static void main(String[] args) { + boolean isAlive = true; + + if(isAlive) System.out.println("alive"); + else System.out.println("not alive"); + } +} diff --git a/v30__boolean_data_type.java b/v30__boolean_data_type.java new file mode 100644 index 0000000..8c1cc7a --- /dev/null +++ b/v30__boolean_data_type.java @@ -0,0 +1,14 @@ +public class v30__boolean_data_type { + public static void main(String[] args) { + boolean b1 = true; + boolean b2 = false; + boolean b3 = 2 < 3; + boolean b4 = 2 > 3; + + System.out.println(b1); + System.out.println(b2); + System.out.println(b3); + System.out.println(b4); + + } +} diff --git a/v31__string_data_type__string_start.java b/v31__string_data_type__string_start.java new file mode 100644 index 0000000..5a1bd0c --- /dev/null +++ b/v31__string_data_type__string_start.java @@ -0,0 +1,13 @@ +public class v31__string_data_type__string_start { + public static void main(String[] args) { + + String name = "Sabbir Hasanat"; + + String u = name.toUpperCase(); + System.out.println(u); + + String l = name.toLowerCase(); + System.out.println(l); + + } +} diff --git a/v32.java b/v32.java new file mode 100644 index 0000000..c43145d --- /dev/null +++ b/v32.java @@ -0,0 +1,26 @@ +public class v32 { + public static void main(String[] args) { + + String s1 = "Sabbir Hasanat"; + System.out.println(s1.toUpperCase()); + + String s2 = s1.toLowerCase(); + System.out.println(s2); + + System.out.println(s1); + + System.out.println(s1.isBlank()); + // System.out.println(s1.isEmpty()); + + char c = s1.charAt(4); //start from [0] + System.out.println(c); + + int i = s1.indexOf('r'); //start from [0] + System.out.println(i); + + String s3 = s1.concat(" Shimul"); + System.out.println(s3); + + + } +} diff --git a/v33__concatenation.java b/v33__concatenation.java new file mode 100644 index 0000000..9a2a928 --- /dev/null +++ b/v33__concatenation.java @@ -0,0 +1,14 @@ +public class v33__concatenation { + public static void main(String[] args) { + String s1 = "Sabbir"; + String s2 = "Hasanat"; + String full = s1+ " "+s2; + + System.out.println(full); + + System.out.println("My id is " + 2 + 5); + System.out.println("My id is " + (2 + 5)); + + System.out.println("Sabbir".concat(" Hasanat").concat(" - 1007")); + } +} diff --git a/v35__string_object_create.java b/v35__string_object_create.java new file mode 100644 index 0000000..8829ffb --- /dev/null +++ b/v35__string_object_create.java @@ -0,0 +1,8 @@ +public class v35__string_object_create { + public static void main(String[] args) { + + // Classname objectname = new Classname(parameters) + + + } +} diff --git a/v38__taking_input.java b/v38__taking_input.java new file mode 100644 index 0000000..57d5479 --- /dev/null +++ b/v38__taking_input.java @@ -0,0 +1,20 @@ +import java.util.*; + +public class v38__taking_input { + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + + // System.out.print("Enter a number: "); + // System.out.println(sc.nextInt()+"\n"+"Enter again a number: "); + + // float f = sc.nextFloat(); + // System.out.println(f); + + System.out.print("String: "); + String s = sc.nextLine(); + System.out.println(s); + + + } +} diff --git a/v51.java b/v51.java new file mode 100644 index 0000000..2cf31da --- /dev/null +++ b/v51.java @@ -0,0 +1,13 @@ +import java.util.*; + +public class v51 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Enter an integer: "); + int n = sc.nextInt(); + + if(n%2==0) System.out.println(n+" is even"); + else System.out.println(n+" is odd"); + } + +} diff --git a/v55.java b/v55.java new file mode 100644 index 0000000..ff4c83c --- /dev/null +++ b/v55.java @@ -0,0 +1,18 @@ +public class v55 { + public static void main(String[] args) { + + int n=10; + switch (n) { + case 10: + System.out.println("= 10"); + break; + + case 90: + System.out.println("= 90"); + break; + + default: + System.out.println("non of the above"); + } + } +} diff --git a/v58.java b/v58.java new file mode 100644 index 0000000..b5a0ada --- /dev/null +++ b/v58.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class v58 { + public static void main(String[] args) { + Scanner s= new Scanner(System.in); + + System.out.print("Enter a four digit number: "); + int n = s.nextInt(); + + if(!(n>999) ) + System.out.println("not four digit number"); + + else { + int n1 = n % 10; + int n2 = (n / 10) % 10; + int n3 = (n / 100) % 10; + int n4 = (n / 1000) % 10; + + if( n1+n2 == n3+n4 ) System.out.println("lucky"); + else System.out.println("not lucky"); + } + + + + } +} diff --git a/v60__Loop_start.java b/v60__Loop_start.java new file mode 100644 index 0000000..34f60c2 --- /dev/null +++ b/v60__Loop_start.java @@ -0,0 +1,18 @@ +import java.util.Scanner; + +public class v60__Loop_start { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + System.out.print("Enter a number between 1 to 10 : "); + int n = s.nextInt(); + + while(n<1 || n>10){ + System.out.print(n+" is not between 1 to 10. Try again: "); + n = s.nextInt(); + } + + System.out.println(n+ " is between 1 to 10. Thanks!"); + } +} diff --git a/v61.java b/v61.java new file mode 100644 index 0000000..3fb6d79 --- /dev/null +++ b/v61.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class v61 { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + int n; + do { + System.out.print("Enter a number between 1 to 10: "); + n = s.nextInt(); + } while(n<1 || n>10); + + System.out.println(n+" is between 1 to 10."); + } +} diff --git a/v67.java b/v67.java new file mode 100644 index 0000000..96c804b --- /dev/null +++ b/v67.java @@ -0,0 +1,18 @@ +import java.util.Scanner; + +public class v67 { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + System.out.print("Enter a number: "); + int n = s.nextInt(); + + int i, sum = 0; + for (i = 1; i <= n / 2; i++) { + if (n % i == 0) + sum += i; + } + System.out.println("sum = " + sum); + } +} diff --git a/v68.java b/v68.java new file mode 100644 index 0000000..437f7bc --- /dev/null +++ b/v68.java @@ -0,0 +1,18 @@ +import java.util.Scanner; + +public class v68 { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + System.out.print("Enter a number: "); + int n = s.nextInt(); + + int i, sum = 0; + for (i = 2; i <= n / 2; i++) { + if (n % i == 0) + sum += i; + } + System.out.println(sum == 1 ? "prime" : "not prime"); + } +} diff --git a/v68_1.java b/v68_1.java new file mode 100644 index 0000000..f44dc5b --- /dev/null +++ b/v68_1.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +public class v68_1 { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + System.out.print("Enter a number: "); + int n = s.nextInt(); + + int i; + + boolean isPrime = true; + for (i = 2; i <= n / 2; i++) { + if (n % i == 0){ + isPrime = false; + break; + } + System.out.println(isPrime? "prime" : "not prime"); + } + } +} diff --git a/v68_1__prime_numbers.java b/v68_1__prime_numbers.java new file mode 100644 index 0000000..67ef905 --- /dev/null +++ b/v68_1__prime_numbers.java @@ -0,0 +1,24 @@ +import java.util.Scanner; + +public class v68_1__prime_numbers { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + System.out.print("Enter n: "); + int n = s.nextInt(); + + int i,count=0; + for(i=2;i<=n;i++){ + if(n%i==0){ + count++; + } + } + + if(count==1){ + System.out.print("prime\n"); + } + else System.out.println("not prime"); + + } +} diff --git a/v69__Loop_finished.java b/v69__Loop_finished.java new file mode 100644 index 0000000..6c80c83 --- /dev/null +++ b/v69__Loop_finished.java @@ -0,0 +1,28 @@ +import java.util.Scanner; + +public class v69__Loop_finished { + public static void main(String[] args) { + + Scanner s= new Scanner(System.in); + + System.out.print("Enter a number: "); + int n = s.nextInt(); + + int max = n; + int min = n; + + while(true){ + n = s.nextInt(); + + if(n<0) + break; + + if(n>max) + max = n; + + if(n<min) + min = n; + } + System.out.println("min= "+min+", max= "+max); + } +} diff --git a/v82.java b/v82.java new file mode 100644 index 0000000..9d919c5 --- /dev/null +++ b/v82.java @@ -0,0 +1,12 @@ +public class v82 { + public static void main(String[] args) { + + point p1 = new point(); + + p1.x = 1; + p1.y = 2; + + System.out.println("x = "+p1.x+", y = "+p1.y); + + } +} diff --git a/v84.java b/v84.java new file mode 100644 index 0000000..829a367 --- /dev/null +++ b/v84.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class v84 { + public static void main(String[] args) { + System.out.print("Enter your name & age: "); + System.out.println("Name: "+getName()+"\nAge: "+getAge()); + + } + public static String getName(){ + return new Scanner(System.in).nextLine(); + } + + public static double getAge(){ + return new Scanner(System.in).nextDouble(); + } +} diff --git a/v85.java b/v85.java new file mode 100644 index 0000000..895ebf3 --- /dev/null +++ b/v85.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class v85 { + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + + // System.out.print("Start from: "); + // int n1 = s.nextInt(); + + System.out.print("End to: "); + int n2 = s.nextInt(); + + int count = 0; + for(int i = 2; i<=n2/2; i++){ + if (n2%i==0) + count++; + + if(count==1) + System.out.print(" "); + } + } +} diff --git a/v86___array_start.java b/v86___array_start.java new file mode 100644 index 0000000..a923639 --- /dev/null +++ b/v86___array_start.java @@ -0,0 +1,28 @@ +import java.util.Scanner; + +public class v86___array_start { + public static void main(String[] args) { + + //for al input + Scanner s = new Scanner(System.in); + + //for a specific array + int a[] = new int[100]; + + System.out.print("Enter size: "); + int n = s.nextInt(); + + System.out.println("Enter elements: "); + for(int i=0;i<n;i++){ + a[i] = s.nextInt(); + } + + System.out.println("Arrays: "); + for(int i=0;i<n;i++){ + System.out.print(a[i]+" "); + } + + + + } +} diff --git a/v87.java b/v87.java new file mode 100644 index 0000000..3e5193c --- /dev/null +++ b/v87.java @@ -0,0 +1,16 @@ +import java.util.Arrays; + +public class v87 { + public static void main(String[] args) { + + int[] a = { 5, -2, 23, 7, 87, -42, 509 }; + + Arrays.sort(a); + + System.out.print("Sorted array: "); + for(int x : a){ + System.out.print(x+" "); + } + + } +} diff --git a/v87_1.java b/v87_1.java new file mode 100644 index 0000000..18bfd35 --- /dev/null +++ b/v87_1.java @@ -0,0 +1,20 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class v87_1 { + public static void main(String[] args) { + int a[] = {2,1,6,4,9,0,-1}; + + Arrays.sort(a); + + System.out.print("Sorted array: "); + for(int x:a){ + System.out.print(x+" "); + } + + System.out.print("\nEnter searching element: "); + System.out.print("Found at index: "+Arrays.binarySearch( a , new Scanner(System.in).nextInt() )); + + + } +} diff --git a/v94.java b/v94.java new file mode 100644 index 0000000..407d935 --- /dev/null +++ b/v94.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class v94 { + public static void main(String[] args) { + int a[] = { 1, 1, 1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 5, 5, 5 }; + + System.out.print("Enter a element: "); + int searchelement = new Scanner(System.in).nextInt(); + + System.out.println(getnumberooc(a, searchelement)); + } + + public static int getnumberooc(int a[], int searchelement) { + int ooc = 0; + for (int i = 0; i < a.length; i++) { + if (searchelement == a[i]) + ooc++; + } + + return ooc; + } + +} \ No newline at end of file