Skip to content

Commit 0861033

Browse files
committed
commit12_18_24
added new folder and file : 8: PatternAddvace Assigement
1 parent a32bcd4 commit 0861033

21 files changed

+464
-26
lines changed

1.Basics/JB_scope.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
public class JB_scope {
3+
public static void main(String[] args) {
4+
5+
// NOTE:
6+
// i. for loop variations:
7+
8+
for (int i = 0, j = 1, k = 3, l = 21; i < args.length; i++) {
9+
System.out.println(i + "" + "" + "" + "" + j + "" + k + "" + l);
10+
}
11+
int x = j + k; // NOTE: we will not be able to access "j" & "k" outside of for loop's scope .
12+
13+
// NOTE:
14+
// 2. noly scopen variations:
15+
//
16+
17+
{
18+
int a = 12;
19+
}
20+
System.out.println(a); // NOTE: we will not be abel to access "a" here out of SCOPE ∴ =
21+
}
22+
}

7.Function_Overloading/'

Lines changed: 0 additions & 20 deletions
This file was deleted.

7.Function_Overloading/JFO_1_4_BinToDesBIGINT.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
// --======================================================================================================
4848
// --PERF:
4949
// --======================================================================================================
50-
// --
5150
// --HEAD:
5251
// --======================================================================================================
5352
// --TAG:
@@ -57,14 +56,21 @@
5756
// --DIV:
5857
// --======================================================================================================
5958
// --
60-
// --RED:
59+
// --R:
6160
// --======================================================================================================
62-
// --BLUE:
61+
// --R2:
6362
// --======================================================================================================
64-
// --GREEN:
63+
// --B:
6564
// --======================================================================================================
66-
// --YELLOW:
65+
// --B2:
66+
// --======================================================================================================
67+
// --G:
68+
// --======================================================================================================
69+
// --G2:
70+
// --======================================================================================================
71+
// --Y:
72+
// --======================================================================================================
73+
// --Y2:
6774
// --======================================================================================================
68-
// --
6975
// --DX:
7076
// --======================================================================================================
1.27 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
import java.util.*;
3+
4+
public class JPA_1_1_holloSquare {
5+
6+
public static void squarePrinter(int row, int cols) {
7+
8+
// NOTE: rows loop:
9+
for (int i = 1; i <= row; i++) {
10+
// NOTE: cols loop:
11+
for (int j = 1; j <= cols; j++) {
12+
// RED: Dignosis
13+
// System.out.println("(" + i + " " + j + ")");
14+
if (i == 1 || i == row || j == 1 || j == cols) {
15+
System.out.print("*");
16+
} else {
17+
System.out.print(" ");
18+
}
19+
}
20+
System.out.println("");
21+
}
22+
23+
}
24+
25+
public static void main(String[] args) {
26+
27+
Scanner sc = new Scanner(System.in);
28+
System.out.println("please inter the number of rows:");
29+
int row = sc.nextInt();
30+
System.out.println("please inter the number of cols:");
31+
int cols = sc.nextInt();
32+
33+
squarePrinter(row, cols);
34+
sc.close();
35+
}
36+
}
893 Bytes
Binary file not shown.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import java.util.*;
2+
3+
public class JPA_1_2_pirimids {
4+
5+
public static void pirimid(int row) {
6+
for (int i = 1; i <= row; i++) {
7+
// System.out.println(i);
8+
for (int j = 1; j <= (row - i); j++) {
9+
// System.out.println(j); TODO: for spaces.
10+
System.out.print(" ");
11+
}
12+
for (int j = 1; j <= i; j++) {
13+
// System.out.println(j); TODO: for stars.
14+
System.out.print("*");
15+
}
16+
System.out.println();
17+
}
18+
19+
}
20+
21+
public static void main(String[] args) {
22+
Scanner sc = new Scanner(System.in);
23+
System.out.println("Please input the number of rows:");
24+
int row = sc.nextInt();
25+
// System.out.println("Please input the number of colls:");
26+
// int coll = sc.nextInt();
27+
28+
pirimid(row);
29+
sc.close();
30+
// WARN::
31+
// =============
32+
// ___* -> row 1 (3 space , 1 star)
33+
// __** -> row 2 (2 space , 2 star)
34+
// _*** -> row 3 (1 space , 3 star)
35+
// **** -> row 4 (0 space , 4 star)
36+
// ↥↥↥↥
37+
// 1234 (colls)
38+
//
39+
// NOTE::
40+
// Here above we can see that
41+
// --
42+
// 1. Num of rows == num of stars
43+
// 2. Num of Spaces == (total rows - running row)
44+
// --
45+
// eg . on row no 3
46+
// Spaces=1, stars=3, row=3, total_rows=4
47+
// so 4-3=1
48+
//
49+
// IMP::
50+
// so we used only rows as input , and use 2 Different loops
51+
// 1 for Spaces and
52+
// 2 for Stars.
53+
//
54+
}
55+
}
907 Bytes
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.util.*;
2+
3+
public class JPA_1_3_pirimidFull {
4+
5+
public static void piramidFull(int row) {
6+
for (int i = 1; i <= row; i++) {
7+
for (int j = 1; j <= (row - i); j++) {
8+
System.out.print(" ");
9+
}
10+
for (int j = 1; j <= ((2 * i) - 1); j++) {
11+
System.out.print("*");
12+
}
13+
14+
System.out.println();
15+
}
16+
17+
}
18+
19+
public static void main(String[] args) {
20+
21+
Scanner sc = new Scanner(System.in);
22+
System.out.println("Please input the number of rows:");
23+
int row = sc.nextInt();
24+
piramidFull(row);
25+
sc.close();
26+
}
27+
// IMP:
28+
// ____* 1 = 1
29+
// ___*** 2 = 3
30+
// __***** 3 = 5
31+
// _******* 4 = 7
32+
// ********* 5 = 9
33+
//
34+
}
841 Bytes
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
3+
public class JPA_1_4_RevNumberPIr {
4+
5+
public static void piramid(int row) {
6+
for (int i = 1; i <= row; i++) {
7+
for (int j = 1; j <= (row - (i - 1)); j++) {
8+
System.out.print(j);
9+
}
10+
System.out.println();
11+
}
12+
13+
}
14+
15+
public static void main(String[] args) {
16+
Scanner sc = new Scanner(System.in);
17+
System.out.println("Please input num of rows:");
18+
int row = sc.nextInt();
19+
piramid(row);
20+
sc.close();
21+
}
22+
}
1.14 KB
Binary file not shown.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import java.util.*;
2+
3+
public class JPA_1_5_BineryTrangle {
4+
5+
public static void binaryTrangle1(int row) {
6+
for (int i = 1; i <= row; i++) {
7+
int bin = (i % 2 == 0) ? 0 : 1;
8+
for (int j = 1; j <= i; j++) {
9+
System.out.print(bin);
10+
bin = (bin == 0) ? 1 : 0;
11+
}
12+
System.out.println();
13+
}
14+
}
15+
16+
public static void binaryTrangle2(int row) {
17+
for (int i = 1; i <= row; i++) {
18+
for (int j = 1; j <= i; j++) {
19+
int res = (i + j) % 2 == 0 ? 1 : 0;
20+
System.out.print(res);
21+
}
22+
System.out.println();
23+
}
24+
}
25+
26+
public static void main(String[] args) {
27+
Scanner sc = new Scanner(System.in);
28+
System.out.println("Please inter total number of Rows:");
29+
int row = sc.nextInt();
30+
31+
System.out.println();
32+
System.out.println("Method 1:");
33+
System.out.println();
34+
binaryTrangle1(row);
35+
System.out.println();
36+
System.out.println("Method 2:");
37+
System.out.println();
38+
binaryTrangle2(row);
39+
sc.close();
40+
41+
}
42+
}
1.16 KB
Binary file not shown.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import java.util.*;
2+
3+
public class JPA_2_1_Butterfly {
4+
5+
public static void butterfly(int row) {
6+
int halfrow = row / 2;
7+
for (int i = 1; i <= halfrow; i++) {
8+
for (int j = 1; j <= i; j++) {
9+
System.out.print("*");
10+
}
11+
for (int j = 1; j < ((halfrow + 1 - i) * 2); j++) {
12+
if ((halfrow + 1 - i) > 1) {
13+
System.out.print(" ");
14+
} else {
15+
System.out.print("*");
16+
}
17+
}
18+
for (int j = 1; j <= i; j++) {
19+
System.out.print("*");
20+
}
21+
System.out.println();
22+
}
23+
for (int i = 1; i <= halfrow; i++) {
24+
for (int j = 1; j <= (halfrow + 1 - i); j++) {
25+
System.out.print("*");
26+
}
27+
for (int j = 1; j < (i * 2); j++) {
28+
if (i < 2) {
29+
System.out.print("*");
30+
} else {
31+
System.out.print(" ");
32+
}
33+
}
34+
for (int j = 1; j <= (halfrow + 1 - i); j++) {
35+
System.out.print("*");
36+
}
37+
System.out.println();
38+
}
39+
}
40+
41+
public static void main(String[] args) {
42+
Scanner sc = new Scanner(System.in);
43+
System.out.println("Inter the number of Rows:");
44+
System.out.println();
45+
int row = sc.nextInt();
46+
System.out.println();
47+
butterfly(row);
48+
sc.close();
49+
50+
}
51+
}
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.util.*;
2+
3+
public class JPA_2_2_ButterflyOptimised {
4+
5+
public static void butterfly(int row) {
6+
int half = row / 2;
7+
// B: 1st : half
8+
for (int i = 1; i <= half; i++) {
9+
butterflyLoop(half, i);
10+
}
11+
// B: 2nd : second half
12+
for (int i = half; i >= 1; i--) {
13+
butterflyLoop(half, i);
14+
}
15+
}
16+
17+
public static void butterflyLoop(int half, int i) {
18+
for (int j = 1; j <= i; j++)
19+
System.out.print("*");
20+
for (int j = 1; j <= (half - i) * 2; j++)
21+
System.out.print(" ");
22+
for (int j = 1; j <= i; j++)
23+
System.out.print("*");
24+
25+
System.out.println();
26+
}
27+
28+
public static void main(String[] args) {
29+
Scanner sc = new Scanner(System.in);
30+
System.out.println("Please input Number of Rows:");
31+
int row = sc.nextInt();
32+
System.out.println();
33+
butterfly(row);
34+
sc.close();
35+
}
36+
}
968 Bytes
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.*;
2+
3+
public class JPA_2_3_rhombusA_B {
4+
5+
public static void rhombus(int l, int b) {
6+
for (int i = 1; i <= b; i++) {
7+
for (int j = 1; j <= (b - i + 1); j++) {
8+
System.out.print(" ");
9+
}
10+
for (int j = 1; j <= l; j++) {
11+
if (i == 1 || j == 1 || i == b || j == l) {
12+
System.out.print("*");
13+
} else {
14+
System.out.print(" ");
15+
}
16+
}
17+
System.out.println();
18+
}
19+
}
20+
21+
public static void main(String[] args) {
22+
Scanner sc = new Scanner(System.in);
23+
System.out.println("Please Inter L:");
24+
int length = sc.nextInt();
25+
System.out.println("Please Inter B:");
26+
int bredth = sc.nextInt();
27+
rhombus(length, bredth);
28+
sc.close();
29+
}
30+
}

Assigements/M10_assigement.class

3.44 KB
Binary file not shown.

0 commit comments

Comments
 (0)