├── অধ্যায় এক _ প্রথম প্রোগ্রাম └── Program1_1.java ├── অধ্যায় চার _ লুপ (Loop ) ├── Program4_2.java ├── Program4_3.java ├── Program4_6.java ├── Program4_4.java ├── Program4_5.java ├── Program4_9.java ├── Program4_10.java ├── Program4_8.java ├── Program4_12.java ├── Program4_13.java ├── Program4_15.java ├── Program4_7.java ├── Program4_14.java ├── Program4_11.java └── Program4_1.java ├── অধ্যায় সাত _ ফাংশন ├── Program7_1.java ├── Program7_7.java ├── Program7_2.java ├── Program7_6.java ├── Program7_9.java ├── Program7_4.java ├── Program7_3.java ├── AreaOfCircle.java └── Program7_8.java ├── অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট ├── Program2_4.java ├── Program2_3.java ├── Program2_5.java ├── Program2_6.java ├── Program2_2.java ├── Program2_1.java ├── Program2_7.java ├── Program2_9.java ├── Program2_16.java ├── Program2_11.java ├── Program2_10.java ├── Program2_12.java ├── Program2_13.java ├── Program2_8.java ├── Program2_14.java └── Program2_15.java ├── অধ্যায় তিন _ কন্ডিশনাল লজিক ├── Program3_5.java ├── Program3_12.java ├── Program3_7.java ├── Program3_1.java ├── Program3_6.java ├── Program3_9.java ├── Program3_2.java ├── Program3_10.java ├── Program3_11.java ├── VowelOrConsonant.java ├── Program3_8.java ├── Program3_3.java ├── Program3_4.java └── RemainderWithoutModulus.java ├── অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা ├── Program13_6.java ├── Program13_5.java ├── Picture13_1.java ├── Program13_2.java ├── Factorial.java ├── Picture13_3.java ├── SortingGivenProblem.java ├── Picture13_2.java ├── Picture13_4.java ├── SortingAnotherWay.java ├── Program13_3.java ├── Program13_7.java ├── Program13_4.java ├── Palindrome.java ├── Program13_1.java ├── EncryptionProblem.java └── GridTraversalProblem.java ├── অধ্যায় ছয় _ অ্যারে ├── Program6_2.java ├── Program6_3.java ├── Program6_7.java ├── Program6_5.java ├── Program6_6.java ├── Program6_4.java ├── Program6_1.java ├── Program6_9.java ├── Program6_8.java ├── Program6_10.java ├── Program6_14.java ├── Program6_12.java ├── Program6_13.java └── Program6_11.java ├── অধ্যায় নয় _ স্ট্রিং (string) ├── Program9_1.java ├── Program9_6.java ├── Program9_2.java ├── Program9_3.java ├── Program9_4.java ├── UppercaseToLowercase.java ├── Program9_5.java ├── Program9_7.java └── StringCompare.java ├── অধ্যায় এগারো _ আবারও অ্যারে ├── Program11_3.java ├── Program11_4.java ├── Program11_5.java ├── Program11_1.java ├── Program11_2.java └── Program11_6.java ├── অধ্যায় পাঁচ _ একটুখানি গণিত ├── Program5_5.java ├── Program5_6.java ├── SumOfOddNumbersUptoN.java ├── Program5_7.java ├── FarenheitToCelsius.java ├── Program5_8.java ├── Program5_9.java ├── Problem4.java ├── Program5_1.java ├── LCM.java ├── Program5_2.java ├── Program5_4.java └── Program5_3.java ├── Problem12.java ├── অধ্যায় বারো _ বাইনারি সংখ্যা ├── Program12_1.java ├── DecimalToBinaryWayOne.java └── DecimalToBinaryWayTwo.java ├── Problem1.java ├── Problem4.java ├── Problem6.java ├── Problem10.java ├── Problem13.java ├── অধ্যায় আট _ বাইনারি সার্চ ├── Program8_1.java └── BinarySearch.java ├── Problem14.java ├── অধ্যায় দশ _ মৌলিক সংখ্যা ├── Program10_2.java └── Program10_1.java ├── Problem2.java ├── Problem3.java ├── Problem7.java ├── Problem8.java ├── Problem11.java ├── Problem9.java ├── Problem5.java ├── Problem16.java └── Problem15.java /অধ্যায় এক _ প্রথম প্রোগ্রাম/Program1_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program1_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | System.out.println("Hello World"); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 1; 8 | 9 | while (n <= 10) { 10 | System.out.printf("%d\n", n); 11 | n++; 12 | } 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | double a, b, c; 8 | a = 2.5; 9 | b = 2.5; 10 | c = a + b; 11 | System.out.printf("%f\n", c); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 1; 8 | 9 | while (n <= 10) { 10 | System.out.printf("%d\n", n); 11 | } 12 | 13 | n++; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int x, y; 8 | 9 | x = 1; 10 | y = x; 11 | x = 2; 12 | 13 | System.out.printf("%d", y); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_5 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int number = 12; 8 | 9 | if (number > 10) { 10 | System.out.printf("The number is greater than ten\n"); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a = 50, b = 60, sum; 8 | 9 | sum = a + b; 10 | 11 | System.out.printf("Sum is %d", sum); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program13_6 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char ch = 'B'; 8 | 9 | ch = (char) ((ch - 'A') + 1 + 65); 10 | 11 | System.out.printf("%c\n", ch); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_5 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a = 50, b = 60, sum; 8 | 9 | sum = a + b; 10 | 11 | System.out.printf("%d + %d = %d", a, b, sum); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int[] my_ara = new int[10]; 8 | 9 | System.out.printf("%d\n", my_ara[0]); 10 | System.out.printf("%d\n", my_ara[9]); 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_6 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a = (int) 50.45, b = 60, sum; 8 | 9 | sum = a + b; 10 | 11 | System.out.printf("%d + %d = %d", a, b, sum); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a, b, sum; 8 | 9 | a = 50; 10 | b = 60; 11 | 12 | sum = a + b; 13 | 14 | System.out.printf("Sum is %d", sum); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int my_ara[] = { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 }; 8 | 9 | System.out.printf("%d\n", my_ara[0]); 10 | System.out.printf("%d\n", my_ara[9]); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_6 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 5; 8 | int i = 1; 9 | 10 | while (i <= 10) { 11 | System.out.printf("%d X %d = %d\n", n, i, n * i); 12 | i = i + 1; 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 1; 8 | 9 | while (n <= 100) { 10 | System.out.printf("%d\n", n); 11 | n++; 12 | 13 | if (n > 10) { 14 | break; 15 | } 16 | } 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_7 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 6, 7, 4, 6, 9 }; 8 | 9 | System.out.printf("%d\n", ara[-1]); 10 | System.out.printf("%d\n", ara[5]); 11 | System.out.printf("%d\n", ara[100]); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_12.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_12 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int num = 5; 8 | 9 | if (num >= 1 || num <= 10) { 10 | System.out.printf("yes\n"); 11 | } else { 12 | System.out.printf("no\n"); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a; 8 | int b; 9 | int sum; 10 | 11 | a = 50; 12 | b = 60; 13 | 14 | sum = a + b; 15 | 16 | System.out.printf("Sum is %d", sum); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program9_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char country[] = { 'B', 'a', 'n', 'g', 'l', 'a', 'd', 'e', 's', 'h', '\0' }; 8 | String str = new String(country); 9 | System.out.printf("%s\n", str); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_5 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 5, 10, 15, 20 }; 8 | 9 | ara[0] = 100; 10 | ara[2] = 200; 11 | ara[3] = 300; 12 | 13 | System.out.printf("%d, %d, %d\n", ara[0], ara[1], ara[2]); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_6 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int numbers[] = { 10, 20, 30, 40, 50 }; 8 | 9 | System.out.printf("First element: %d\n", numbers[0]); 10 | System.out.printf("Third element: %d\n", numbers[2]); 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_5 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 0; 8 | 9 | while (n < 10) { 10 | n = n + 1; 11 | 12 | if (n % 2 == 0) { 13 | continue; 14 | } 15 | System.out.printf("%d\n", n); 16 | } 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_9 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int m, n = 5; 8 | int i; 9 | 10 | m = 0; 11 | 12 | for (i = 1; i <= 10; i = i + 1) { 13 | m = m + n; 14 | System.out.printf("%d X %d = %d\n", n, i, m); 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int[] my_ara = new int[10]; 8 | my_ara[0] = 5; 9 | my_ara[1] = 10; 10 | my_ara[2] = 15; 11 | my_ara[3] = 20; 12 | 13 | System.out.printf("%d, %d\n", my_ara[0], my_ara[9]); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_7 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 10; 8 | 9 | if (n < 30) { 10 | System.out.printf("n is less than 30.\n"); 11 | } 12 | if (n < 50) { 13 | System.out.printf("n is less than 50.\n"); 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n; 8 | 9 | n = 10; 10 | 11 | if (n >= 0) { 12 | System.out.printf("The number is positive\n"); 13 | } else { 14 | System.out.printf("The number is negative\n"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_6 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 10; 8 | 9 | if (n < 30) { 10 | System.out.printf("n is less than 30.\n"); 11 | } else if (n < 50) { 12 | System.out.printf("n is less than 50.\n"); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_9 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int number = 9; 8 | 9 | if (number % 2 == 0) { 10 | System.out.printf("The number is even\n"); 11 | } else { 12 | System.out.printf("The number is odd\n"); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_7 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n; 8 | double x; 9 | 10 | x = 10.5; 11 | n = (int) x; 12 | 13 | System.out.printf("Value of n is %d\n", n); 14 | System.out.printf("Value of x is %f\n", x); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n; 8 | 9 | n = 10; 10 | 11 | if (n < 0) { 12 | System.out.printf("The number is negative\n"); 13 | } else { 14 | System.out.printf("The number is positive\n"); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program13_5 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char ch1 = 67, ch2 = 68, ch3 = 69, ch4 = 99, ch5 = 100, ch6 = 101; 8 | 9 | System.out.printf("%c%c%c\n", ch1, ch2, ch3); 10 | System.out.printf("%c%c%c\n", ch4, ch5, ch6); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_7 { 4 | 5 | static double pi = 3.14; 6 | 7 | static void my_fnc() { 8 | pi = 3.1416; 9 | return; 10 | } 11 | 12 | public static void main(String[] args) { 13 | // TODO Auto-generated method stub 14 | System.out.printf("%f\n", pi); 15 | my_fnc(); 16 | System.out.printf("%f\n", pi); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_10.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_10 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n, i; 8 | 9 | for (i = 1; i <= 20; i++) { 10 | for (n = 1; n <= 10; n++) { 11 | System.out.printf("%d X %d = %d\n", i, n, i * n); 12 | } 13 | System.out.printf("\n"); 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_8 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 5; 8 | int i = 1; 9 | 10 | for (;;) { 11 | if (i > 10) { 12 | break; 13 | } 14 | 15 | System.out.printf("%d X %d = %d\n", n, i, n * i); 16 | i = i + 1; 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_2 { 4 | 5 | static double add(double num1, double num2) { 6 | double sum = num1 + num2; 7 | return sum; 8 | } 9 | 10 | public static void main(String[] args) { 11 | // TODO Auto-generated method stub 12 | double a, b, c; 13 | 14 | a = b = 2.5; 15 | c = add(a, b); 16 | System.out.printf("%f\n", c); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_12.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_12 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a, b, c; 8 | 9 | for (a = 1; a <= 3; a++) { 10 | for (b = 1; b <= 3; b++) { 11 | for (c = 1; c <= 3; c++) { 12 | System.out.printf("%d, %d, %d\n", a, b, c); 13 | } 14 | } 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় এগারো _ আবারও অ্যারে/Program11_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program11_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | String[] saarc = { "Bangladesh", "India", "Pakistan", "Sri Lanka", "Nepal", "Bhutan", "Maldives" }; 8 | int row; 9 | 10 | for (row = 0; row < 7; row++) { 11 | System.out.printf("%s\n", saarc[row]); 12 | } 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_6 { 4 | 5 | static int test_function(int x) { 6 | int y = x; 7 | x = 2 * y; 8 | return (x * y); 9 | } 10 | 11 | public static void main(String[] args) { 12 | // TODO Auto-generated method stub 13 | int x = 10, y = 20, z = 30; 14 | 15 | z = test_function(x); 16 | System.out.printf("%d %d %d\n", x, y, z); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_10.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_10 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char ch = 'W'; 8 | 9 | if (ch >= 'a' && ch <= 'z') { 10 | System.out.printf("%c is lower case\n", ch); 11 | } 12 | if (ch >= 'A' && ch <= 'Z') { 13 | System.out.printf("%c is upper case\n", ch); 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_11.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_11 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char ch = 'k'; 8 | 9 | if (ch >= 'a' && ch <= 'z') { 10 | System.out.printf("%c is lower case\n", ch); 11 | } else if (ch >= 'A' && ch <= 'Z') { 12 | System.out.printf("%c is upper case\n", ch); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_5 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int n, sum; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | n = scan.nextInt(); 13 | scan.close(); 14 | sum = (n * (n + 1)) / 2; 15 | 16 | System.out.printf("Summation is %d\n", sum); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_9 { 4 | 5 | static void test_function(int ara[]) { 6 | ara[0] = 100; 7 | return; 8 | } 9 | 10 | public static void main(String[] args) { 11 | // TODO Auto-generated method stub 12 | int ara[] = { 1, 2, 3, 4, 5 }; 13 | 14 | System.out.printf("%d\n", ara[0]); 15 | test_function(ara); 16 | System.out.printf("%d\n", ara[0]); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/VowelOrConsonant.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class VowelOrConsonant { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char ch = 'i'; 8 | 9 | if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') { 10 | System.out.printf("%c is vowel\n", ch); 11 | } else { 12 | System.out.printf("%c is consonant\n", ch); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program9_6 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | String ara; 11 | 12 | while (scan.hasNext()) { 13 | ara = scan.nextLine(); 14 | System.out.printf("%s\n", ara); 15 | } 16 | 17 | scan.close(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_13.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_13 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a, b, c; 8 | 9 | for (a = 1; a <= 3; a++) { 10 | for (b = 1; b <= 3 && b != a; b++) { 11 | for (c = 1; c <= 3 && c != a && c != b; c++) { 12 | System.out.printf("%d, %d, %d\n", a, b, c); 13 | } 14 | } 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program9_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char country[] = { 'B', 'a', 'n', 'g', 'l', 'a', 'd', 'e', 's', 'h', ' ', 'i', 's', ' ', 'm', 'y', ' ', 'c', 8 | 'o', 'u', 'n', 't', 'r', 'y' }; 9 | 10 | String str = new String(country); 11 | System.out.printf("%s\n", str); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program9_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char country[] = { 'B', 'a', 'n', 'g', 'l', 'a', 'd', 'e', 's', 'h', '\0', 'i', 's', ' ', 'm', 'y', ' ', 'c', 8 | 'o', 'u', 'n', 't', 'r', 'y', '\0' }; 9 | 10 | String str = new String(country); 11 | System.out.printf("%s\n", str); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_4 { 4 | 5 | // we don't need method prototype in Java 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double a = 2.8, b = 2.7, c; 10 | c = add(a, b); 11 | System.out.printf("%f\n", c); 12 | } 13 | 14 | static double add(double n1, double n2) { 15 | double sum = n1 + n2; 16 | return sum; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_8 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int number, remainder; 8 | 9 | number = 5; 10 | 11 | remainder = number % 2; 12 | 13 | if (remainder == 0) { 14 | System.out.printf("The number is even\n"); 15 | } else { 16 | System.out.printf("The number is odd\n"); 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_9 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | double a, b, sum; 8 | 9 | a = 9.5; 10 | b = 8.743; 11 | 12 | sum = a + b; 13 | 14 | System.out.printf("Sum is: %f\n", sum); 15 | System.out.printf("Sum is: %.2f\n", sum); 16 | // System.out.printf("Sum is: %.0f\n", sum); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 10; 8 | 9 | if (n < 0) { 10 | System.out.printf("The number is negative\n"); 11 | } else if (n > 0) { 12 | System.out.printf("The number is positive\n"); 13 | } else if (n == 0) { 14 | System.out.printf("The number is zero!\n"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/Program3_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program3_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 10; 8 | 9 | if (n < 0) { 10 | System.out.printf("The number is negative\n"); 11 | } else if (n > 0) { 12 | System.out.printf("The number is positive\n"); 13 | } else { 14 | System.out.printf("The number is zero!\n"); 15 | } 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_16.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_16 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | // test program - comment 1 8 | System.out.printf("Hello "); 9 | /* 10 | * We have printed Hello, now we shall print World. Note that this is a 11 | * multi-line comment 12 | */ 13 | System.out.printf("World"); // printed world 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ft_marks, st_marks, final_marks; 8 | double total_marks; 9 | 10 | ft_marks = 80; 11 | st_marks = 74; 12 | final_marks = 97; 13 | 14 | total_marks = ft_marks / 4.0 + st_marks / 4.0 + final_marks / 2.0; 15 | System.out.printf("%.0f\n", total_marks); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /অধ্যায় তিন _ কন্ডিশনাল লজিক/RemainderWithoutModulus.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class RemainderWithoutModulus { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int number, remainder, quotient, maxValue; 8 | 9 | number = 11; 10 | 11 | quotient = number / 2; 12 | maxValue = quotient * 2; 13 | remainder = number - maxValue; 14 | 15 | System.out.printf("Remainder is %d\n", remainder); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_15.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_15 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a, b, c; 8 | 9 | for (a = 1; a <= 3; a++) { 10 | for (b = 1; b <= 3; b++) { 11 | for (c = 1; c <= 3; c++) { 12 | if (b != a && c != a && c != b) { 13 | System.out.printf("%d, %d, %d\n", a, b, c); 14 | } 15 | } 16 | } 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_3 { 4 | 5 | double add(double n1, double n2) { 6 | double sum = n1 + n2; 7 | return sum; 8 | } 9 | 10 | public static void main(String[] args) { 11 | // TODO Auto-generated method stub 12 | double a, b, c; 13 | Program7_3 object = new Program7_3(); 14 | 15 | a = 2.8; 16 | b = 2.7; 17 | 18 | c = object.add(a, b); 19 | 20 | System.out.printf("%f\n", c); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_11.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program2_11 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double a, b, sum; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | a = scan.nextDouble(); 13 | b = scan.nextDouble(); 14 | scan.close(); 15 | 16 | sum = a + b; 17 | 18 | System.out.printf("Sum is: %f\n", sum); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/AreaOfCircle.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class AreaOfCircle { 4 | 5 | public static final double PI = 3.14159; 6 | 7 | static double find_circle_area(double radius) { 8 | return PI * radius * radius; 9 | } 10 | 11 | public static void main(String[] args) { 12 | // TODO Auto-generated method stub 13 | double radius = 3; 14 | 15 | double area = find_circle_area(radius); 16 | 17 | System.out.printf("%.2f\n", area); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_6 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int i, n, sum; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | n = scan.nextInt(); 13 | scan.close(); 14 | 15 | for (i = 1, sum = 0; i <= n; i++) { 16 | sum = sum + i; 17 | } 18 | System.out.printf("Summation is %d\n", sum); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_7 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int n = 5; 8 | int i; 9 | 10 | for (i = 1; i <= 10; i = i + 1) { 11 | System.out.printf("%d X %d = %d\n", n, i, n * i); 12 | } 13 | 14 | /* 15 | * int i = 1; 16 | * 17 | * for (; i <= 10; i = i + 1) { System.out.printf("%d X %d = %d\n", n, i, n * 18 | * i); } 19 | */ 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_14.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_14 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a, b, c; 8 | 9 | for (a = 1; a <= 3; a++) { 10 | for (b = 1; b <= 3; b++) { 11 | if (b != a) { 12 | for (c = 1; c <= 3; c++) { 13 | if (c != a && c != b) { 14 | System.out.printf("%d, %d, %d\n", a, b, c); 15 | } 16 | } 17 | } 18 | } 19 | } 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_10.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.io.IOException; 4 | import java.util.Scanner; 5 | 6 | public class Program2_10 { 7 | 8 | public static void main(String[] args) throws IOException { 9 | // TODO Auto-generated method stub 10 | int a, b, sum; 11 | Scanner scan = new Scanner(System.in); 12 | 13 | a = scan.nextInt(); 14 | b = scan.nextInt(); 15 | 16 | sum = a + b; 17 | 18 | System.out.printf("Sum is: %d\n", sum); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/SumOfOddNumbersUptoN.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class SumOfOddNumbersUptoN { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int i, n, sum; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | n = scan.nextInt(); 13 | scan.close(); 14 | 15 | for (i = 1, sum = 0; i <= n; i += 2) { 16 | sum = sum + i; 17 | } 18 | System.out.printf("Summation is %d\n", sum); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_12.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program2_12 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | char ch; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter the first letter of your name: "); 13 | 14 | ch = scan.next().charAt(0); 15 | scan.close(); 16 | 17 | System.out.printf("The first letter of your name is: %c\n", ch); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Picture13_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Picture13_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int counter = 7; 8 | 9 | for (int i = 0; i < 13; i++) { 10 | 11 | for (int j = 0; j < counter; j++) { 12 | System.out.printf("c"); 13 | } 14 | 15 | System.out.printf("\n"); 16 | 17 | if (i >= (int) (13 / 2)) { 18 | counter++; 19 | } else { 20 | counter--; 21 | } 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_13.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program2_13 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | char[] ch = new char[1]; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter the first letter of your name: "); 13 | 14 | scan.next().getChars(0, 1, ch, 0); 15 | scan.close(); 16 | 17 | System.out.printf("The first letter of your name is: %c\n", ch[0]); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_9 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; 8 | int[] ara2 = new int[10]; 9 | int i, j; 10 | 11 | for (i = 0, j = 9; i < 10; i++, j--) { 12 | ara2[j] = ara[i]; 13 | } 14 | 15 | for (i = 0; i < 10; i++) { 16 | ara[i] = ara2[i]; 17 | } 18 | 19 | for (i = 0; i < 10; i++) { 20 | System.out.printf("%d\n", ara[i]); 21 | } 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_8 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; 8 | 9 | int i; 10 | 11 | for (i = 0; i < 10; i++) { 12 | System.out.printf("%d th element is: %d\n", i + 1, ara[i]); 13 | } 14 | 15 | /* 16 | * System.out.println(); 17 | * 18 | * for (i = 9; i >= 0; i--) { System.out.printf("%d th element is: %d\n", i + 1, 19 | * ara[i]); } 20 | */ 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_7 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double celsius, farenheit; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter the temperature in celsius: "); 13 | 14 | celsius = scan.nextDouble(); 15 | scan.close(); 16 | 17 | farenheit = 1.8 * celsius + 32; 18 | 19 | System.out.printf("Temperature in farenheit is: %f\n", farenheit); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_10.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_10 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; 8 | int i, j, temp; 9 | 10 | for (i = 0, j = 9; i < 10; i++, j--) { 11 | if (i > j) { 12 | break; 13 | } 14 | else { 15 | temp = ara[j]; 16 | ara[j] = ara[i]; 17 | ara[i] = temp; 18 | } 19 | } 20 | 21 | for (i = 0; i < 10; i++) { 22 | System.out.printf("%d\n", ara[i]); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_11.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program4_11 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int n, m, i, j; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | n = scan.nextInt(); 13 | 14 | for (i = 0; i < n; i++) { 15 | m = scan.nextInt(); 16 | 17 | for (j = 10; j <= m; j++) { 18 | if (j % 11 == 0) { 19 | continue; 20 | } 21 | 22 | System.out.printf("%d\n", j); 23 | } 24 | } 25 | scan.close(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/FarenheitToCelsius.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class FarenheitToCelsius { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double celsius, farenheit; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter the temperature in farenheit: "); 13 | 14 | farenheit = scan.nextDouble(); 15 | scan.close(); 16 | 17 | celsius = (farenheit - 32) / 1.8; 18 | 19 | System.out.printf("Temperature in celsius is: %f\n", celsius); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /অধ্যায় চার _ লুপ (Loop )/Program4_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program4_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | System.out.printf("1\n"); 8 | System.out.printf("2\n"); 9 | System.out.printf("3\n"); 10 | System.out.printf("4\n"); 11 | System.out.printf("5\n"); 12 | System.out.printf("6\n"); 13 | System.out.printf("7\n"); 14 | System.out.printf("8\n"); 15 | System.out.printf("9\n"); 16 | System.out.printf("10\n"); 17 | 18 | // System.out.printf("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় এগারো _ আবারও অ্যারে/Program11_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program11_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | String[] saarc = { "Bangladesh", "India", "Pakistan", "Sri Lanka", "Nepal", "Bhutan", "Maldives" }; 8 | int row, col, name_length; 9 | 10 | for (row = 0; row < 7; row++) { 11 | name_length = saarc[row].length(); 12 | 13 | for (col = 0; col < name_length; col++) { 14 | System.out.printf("%c\n", saarc[row].charAt(col)); 15 | } 16 | 17 | System.out.printf("\n"); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় এগারো _ আবারও অ্যারে/Program11_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program11_5 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | String[] saarc = { "Bangladesh", "India", "Pakistan", "Sri Lanka", "Nepal", "Bhutan", "Maldives" }; 8 | int row, col, name_length; 9 | 10 | for (row = 0; row < 7; row++) { 11 | name_length = saarc[row].length(); 12 | 13 | for (col = 0; col < name_length; col++) { 14 | System.out.printf("(%d, %d) = %c, ", row, col, saarc[row].charAt(col)); 15 | } 16 | 17 | System.out.printf("\n"); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_14.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_14 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int i, j; 8 | int total_marks[] = { 6, 7, 4, 6, 9, 7, 6, 2, 4, 3, 4, 1 }; 9 | int[] marks_count = new int[11]; 10 | 11 | for (i = 0; i < 11; i++) { 12 | marks_count[i] = 0; 13 | } 14 | 15 | for (i = 0; i < 12; i++) { 16 | marks_count[total_marks[i]]++; 17 | 18 | for (j = 0; j <= 10; j++) { 19 | System.out.printf("%d ", marks_count[j]); 20 | } 21 | 22 | System.out.printf("\n"); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_8 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int a, b, x, gcd = 0; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | a = scan.nextInt(); 13 | b = scan.nextInt(); 14 | scan.close(); 15 | 16 | if (a < b) { 17 | x = a; 18 | } else { 19 | x = b; 20 | } 21 | 22 | for (; x >= 1; x--) { 23 | if (a % x == 0 && b % x == 0) { 24 | gcd = x; 25 | break; 26 | } 27 | } 28 | System.out.printf("GCD is %d\n", gcd); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program13_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara1[] = { 3, 1, 5, 2, 4 }; 8 | int ara2[] = new int[5]; 9 | 10 | int i, minimum, index_2; 11 | 12 | for (index_2 = 0; index_2 < 5; index_2++) { 13 | minimum = 10000; 14 | 15 | for (i = 0; i < 5; i++) { 16 | if (ara1[i] < minimum) { 17 | minimum = ara1[i]; 18 | } 19 | } 20 | ara2[index_2] = minimum; 21 | } 22 | for (i = 0; i < 5; i++) { 23 | System.out.printf("%d\n", ara2[i]); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_9 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int a, b, t, gcd; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | a = scan.nextInt(); 13 | b = scan.nextInt(); 14 | scan.close(); 15 | 16 | if (a == 0) { 17 | gcd = a; 18 | } else if (b == 0) { 19 | gcd = b; 20 | } else { 21 | while (b != 0) { 22 | t = b; 23 | b = a % b; 24 | a = t; 25 | } 26 | gcd = a; 27 | } 28 | System.out.printf("GCD is %d\n", gcd); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Factorial.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Factorial { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int number, factorial = 1; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | number = scan.nextInt(); 13 | scan.close(); 14 | 15 | if (number == 0 || number == 1) { 16 | System.out.printf("Factorial is %d\n", factorial); 17 | } else { 18 | for (int i = number; i >= 1; i--) { 19 | factorial = factorial * i; 20 | } 21 | System.out.printf("Factorial is %d\n", factorial); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Problem12.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem12 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | 10 | Scanner input = new Scanner(System.in); 11 | int T = input.nextInt(); 12 | 13 | for (int i = 0; i < T; i++) { 14 | int n = input.nextInt(); 15 | System.out.println(evenodd(n)); 16 | } 17 | input.close(); 18 | 19 | } 20 | 21 | public static String evenodd(int n) { 22 | String result = ""; 23 | if (n % 2 == 0) { 24 | result = "even"; 25 | } else if (n % 2 != 0) { 26 | result = "odd"; 27 | } 28 | return result; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program9_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char country[] = { 'B', 'a', 'n', 'g', 'l', 'a', 'd', 'e', 's', 'h' }; 8 | int i, length; 9 | String str = new String(country); 10 | 11 | System.out.printf("%s\n", str); 12 | 13 | length = 10; 14 | 15 | for (i = 0; i < length; i++) { 16 | if (country[i] >= 97 && country[i] <= 122) { 17 | country[i] = (char) ('A' + (country[i] - 'a')); 18 | } 19 | } 20 | 21 | str = new String(country); 22 | System.out.printf("%s\n", str); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program2_8 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int a; 8 | 9 | a = 1000; 10 | System.out.printf("Value of a is %d", a); 11 | 12 | a = -21000; 13 | System.out.printf("Value of a is %d", a); 14 | 15 | a = 10000000; 16 | System.out.printf("Value of a is %d", a); 17 | 18 | a = -10000000; 19 | System.out.printf("Value of a is %d", a); 20 | 21 | a = 100020004000503; 22 | System.out.printf("Value of a is %d", a); 23 | 24 | a = -4325987632; 25 | System.out.printf("Value of a is %d", a); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/UppercaseToLowercase.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class UppercaseToLowercase { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | char country[] = { 'B', 'a', 'n', 'G', 'l', 'a', 'd', 'E', 's', 'H' }; 8 | int i, length; 9 | String str = new String(country); 10 | 11 | System.out.printf("%s\n", str); 12 | 13 | length = 10; 14 | 15 | for (i = 0; i < length; i++) { 16 | if (country[i] >= 65 && country[i] <= 90) { 17 | country[i] = (char) ('a' + (country[i] - 'A')); 18 | } 19 | } 20 | 21 | str = new String(country); 22 | System.out.printf("%s\n", str); 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Problem4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem4 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double time_passed, final_velocity, distance; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter final velocity (v): "); 13 | final_velocity = scan.nextDouble(); 14 | 15 | System.out.printf("Enter time passed (t): "); 16 | time_passed = scan.nextDouble(); 17 | scan.close(); 18 | 19 | distance = 2 * time_passed * final_velocity; 20 | 21 | System.out.printf("Distance crossed in 2t: %.2f\n", distance); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_1 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double x, y, x_plus_y, x_minus_y; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter the value of x + y: "); 13 | x_plus_y = scan.nextDouble(); 14 | 15 | System.out.printf("Enter the value of x - y:"); 16 | x_minus_y = scan.nextDouble(); 17 | scan.close(); 18 | 19 | x = (x_plus_y + x_minus_y) / 2; 20 | y = (x_plus_y - x_minus_y) / 2; 21 | 22 | System.out.printf("x = %.2f, y = %.2f\n", x, y); 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_12.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_12 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int marks, i, count; 8 | int total_marks[] = { 86, 78, 94, 68, 92, 78, 64, 62, 72, 61, 72, 66, 65, 65, 80, 72, 62, 68, 81, 62, 56, 68, 9 | 58, 56, 82, 70, 74, 78, 76, 84, 88, 73, 62, 66, 76, 70, 67, 65, 77, 63 }; 10 | 11 | for (marks = 50; marks <= 100; marks++) { 12 | count = 0; 13 | 14 | for (i = 0; i < 40; i++) { 15 | if (total_marks[i] == marks) { 16 | count++; 17 | } 18 | } 19 | 20 | System.out.printf("Marks: %d Count: %d\n", marks, count); 21 | } 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Picture13_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Picture13_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int spaceCounter = 0; 8 | int cCounter = 7; 9 | 10 | for (int i = 0; i < 13; i++) { 11 | for (int j = 0; j < spaceCounter; j++) { 12 | System.out.printf(" "); 13 | } 14 | 15 | for (int j = 0; j < cCounter; j++) { 16 | System.out.printf("c"); 17 | } 18 | 19 | System.out.printf("\n"); 20 | 21 | if (i >= (int) (13 / 2)) { 22 | spaceCounter--; 23 | cCounter++; 24 | } else { 25 | spaceCounter++; 26 | cCounter--; 27 | } 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/SortingGivenProblem.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class SortingGivenProblem { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara1[] = { 3, 1, 5, 2, 4 }; 8 | 9 | int i, minimum, index_2; 10 | 11 | for (index_2 = 0; index_2 < 5; index_2++) { 12 | minimum = ara1[index_2]; 13 | 14 | for (i = index_2 + 1; i < 5; i++) { 15 | if (ara1[i] < minimum) { 16 | minimum = ara1[i]; 17 | ara1[i] = ara1[index_2]; 18 | ara1[index_2] = minimum; 19 | } 20 | } 21 | 22 | } 23 | 24 | for (i = 0; i < 5; i++) { 25 | System.out.printf("%d\n", ara1[i]); 26 | } 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Picture13_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Picture13_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int spaceCounter = 0; 8 | int cCounter = 11; 9 | 10 | for (int i = 0; i < 11; i++) { 11 | for (int j = 0; j < spaceCounter; j++) { 12 | System.out.printf(" "); 13 | } 14 | 15 | for (int j = 0; j < cCounter; j++) { 16 | System.out.printf("c"); 17 | } 18 | 19 | System.out.printf("\n"); 20 | 21 | if (i >= (int) (11 / 2)) { 22 | spaceCounter--; 23 | cCounter += 2; 24 | } else { 25 | spaceCounter++; 26 | cCounter -= 2; 27 | } 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /অধ্যায় বারো _ বাইনারি সংখ্যা/Program12_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program12_1 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | 10 | String binary; 11 | int len, decimal, power, i; 12 | Scanner scan = new Scanner(System.in); 13 | 14 | System.out.printf("Enter the binary number: "); 15 | binary = scan.next(); 16 | 17 | decimal = 0; 18 | len = binary.length(); 19 | power = len - 1; 20 | 21 | for (i = 0; i < len; i++) { 22 | decimal += (binary.charAt(i) - '0') * Math.pow(2, power); 23 | power--; 24 | } 25 | 26 | System.out.printf("Decimal value is %d\n", decimal); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Picture13_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Picture13_4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int spaceCounter = 18; 8 | int cCounter = 2; 9 | 10 | for (int i = 0; i < 10; i++) { 11 | 12 | for (int j2 = 0; j2 < cCounter / 2; j2++) { 13 | System.out.printf("c"); 14 | } 15 | 16 | for (int j2 = 0; j2 < spaceCounter; j2++) { 17 | System.out.printf(" "); 18 | } 19 | 20 | for (int j2 = cCounter / 2; j2 < cCounter; j2++) { 21 | System.out.printf("c"); 22 | } 23 | 24 | cCounter += 2; 25 | spaceCounter -= 2; 26 | System.out.printf("\n"); 27 | } 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Problem1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem1 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | int numberCount, negativeCount = 0, positiveCount = 0; 11 | int[] n; 12 | 13 | numberCount = scan.nextInt(); 14 | n = new int[numberCount]; 15 | 16 | for (int i = 0; i < n.length; i++) { 17 | n[i] = scan.nextInt(); 18 | } 19 | scan.close(); 20 | 21 | for (int i = 0; i < n.length; i++) { 22 | if (n[i] < 0) { 23 | negativeCount++; 24 | } else { 25 | positiveCount++; 26 | } 27 | } 28 | 29 | System.out.printf("%d %d", positiveCount, negativeCount); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_13.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_13 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int i; 8 | int total_marks[] = { 86, 78, 94, 68, 92, 78, 64, 62, 72, 61, 72, 66, 65, 65, 80, 72, 62, 68, 81, 62, 56, 68, 9 | 58, 56, 82, 70, 74, 78, 76, 84, 88, 73, 62, 66, 76, 70, 67, 65, 77, 63 }; 10 | int[] marks_count = new int[101]; 11 | 12 | for (i = 0; i < 101; i++) { 13 | marks_count[i] = 0; 14 | } 15 | 16 | for (i = 0; i < 40; i++) { 17 | marks_count[total_marks[i]]++; 18 | } 19 | 20 | for (i = 50; i <= 100; i++) { 21 | System.out.printf("Marks: %d Count: %d\n", i, marks_count[i]); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/SortingAnotherWay.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class SortingAnotherWay { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara1[] = { 3, 1, 5, 2, 4 }; 8 | int ara2[] = new int[5]; 9 | 10 | int i, minimum, index_2; 11 | 12 | for (index_2 = 0; index_2 < 5; index_2++) { 13 | minimum = 10000; 14 | 15 | for (i = index_2; i < 5; i++) { 16 | if (ara1[i] < minimum) { 17 | minimum = ara1[i]; 18 | ara1[i] = ara1[index_2]; 19 | ara1[index_2] = minimum; 20 | } 21 | } 22 | ara2[index_2] = minimum; 23 | } 24 | for (i = 0; i < 5; i++) { 25 | System.out.printf("%d\n", ara2[i]); 26 | } 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Problem4.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Problem4 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | Scanner scan = new Scanner(System.in); 8 | int[] sum; 9 | int N; 10 | char[] wordInArray; 11 | 12 | N = scan.nextInt(); 13 | scan.nextLine(); 14 | sum = new int[N]; 15 | 16 | for (int i = 0; i < N; i++) { 17 | int individualSum = 0; 18 | wordInArray = scan.nextLine().toCharArray(); 19 | 20 | for (char c : wordInArray) { 21 | individualSum = individualSum + (int) c; 22 | } 23 | 24 | sum[i] = individualSum; 25 | } 26 | scan.close(); 27 | 28 | for (int i = 0; i < sum.length; i++) { 29 | System.out.printf("%d\n", sum[i]); 30 | } 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program13_3 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara1[] = { 3, 1, 5, 2, 4 }; 8 | int ara2[] = new int[5]; 9 | 10 | int i, minimum, index_2, minimum_index = 0; 11 | 12 | for (index_2 = 0; index_2 < 5; index_2++) { 13 | minimum = 10000; 14 | 15 | for (i = 0; i < 5; i++) { 16 | if (ara1[i] < minimum) { 17 | minimum = ara1[i]; 18 | minimum_index = i; 19 | } 20 | } 21 | 22 | ara1[minimum_index] = 10000; 23 | ara2[index_2] = minimum; 24 | } 25 | 26 | for (i = 0; i < 5; i++) { 27 | System.out.printf("%d\n", ara2[i]); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Problem6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem6 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | int N, number, root; 11 | String[] answers; 12 | 13 | N = scan.nextInt(); 14 | scan.nextLine(); 15 | answers = new String[N]; 16 | 17 | for (int i = 0; i < N; i++) { 18 | number = scan.nextInt(); 19 | 20 | root = (int) Math.sqrt(number); 21 | 22 | if (Math.pow(root, 2) == number) { 23 | answers[i] = "YES"; 24 | } else { 25 | answers[i] = "NO"; 26 | } 27 | } 28 | scan.close(); 29 | 30 | for (String string : answers) { 31 | System.out.printf("%s\n", string); 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Problem10.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem10 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | int[] digitCount; 11 | int N, number; 12 | 13 | N = scan.nextInt(); 14 | scan.nextLine(); 15 | digitCount = new int[N]; 16 | 17 | for (int i = 0; i < N; i++) { 18 | number = scan.nextInt(); 19 | 20 | while (number < 0 || number > 10000001) { 21 | number = scan.nextInt(); 22 | 23 | } 24 | 25 | digitCount[i] = Integer.toString(number).length(); 26 | } 27 | scan.close(); 28 | 29 | for (int i = 0; i < digitCount.length; i++) { 30 | System.out.printf("%d\n", digitCount[i]); 31 | } 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program13_7 { 6 | 7 | public static void encrypt(char msg[]) { 8 | int i, n; 9 | 10 | n = msg.length; 11 | 12 | for (i = 0; i < n; i++) { 13 | if (msg[i] >= 'a' && msg[i] <= 'z') { 14 | msg[i] = (char) (msg[i] + 1); 15 | } else if (msg[i] >= 'A' && msg[i] <= 'Z') { 16 | msg[i] = (char) (msg[i] + 1); 17 | } 18 | } 19 | } 20 | 21 | public static void main(String[] args) { 22 | // TODO Auto-generated method stub 23 | 24 | char[] s; 25 | Scanner scan = new Scanner(System.in); 26 | 27 | s = scan.nextLine().toCharArray(); 28 | scan.close(); 29 | 30 | encrypt(s); 31 | 32 | System.out.printf("%s\n", String.valueOf(s)); 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_14.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program2_14 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int num1, num2; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Please enter a number: "); 13 | num1 = scan.nextInt(); 14 | 15 | System.out.printf("Please enter another number: "); 16 | num2 = scan.nextInt(); 17 | 18 | scan.close(); 19 | 20 | System.out.printf("%d + %d = %d\n", num1, num2, num1 + num2); 21 | System.out.printf("%d - %d = %d\n", num1, num2, num1 - num2); 22 | System.out.printf("%d * %d = %d\n", num1, num2, num1 * num2); 23 | System.out.printf("%d / %d = %d\n", num1, num2, num1 / num2); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program13_4 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int x, y; 10 | char c; 11 | Scanner scan = new Scanner(System.in); 12 | 13 | System.out.printf("Please enter the initial position: "); 14 | x = scan.nextInt(); 15 | y = scan.nextInt(); 16 | 17 | while (true) { 18 | c = scan.next().charAt(0); 19 | 20 | if (c == 'S') { 21 | break; 22 | } else if (c == 'U') { 23 | x--; 24 | } else if (c == 'D') { 25 | x++; 26 | } else if (c == 'R') { 27 | y++; 28 | } else if (c == 'L') { 29 | y--; 30 | } 31 | } 32 | 33 | System.out.printf("Final position of the robot is: %d, %d\n", x, y); 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/LCM.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class LCM { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int a, b, t, x, y, gcd; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | a = scan.nextInt(); 13 | b = scan.nextInt(); 14 | scan.close(); 15 | 16 | x = a; 17 | y = b; 18 | 19 | if (a == 0 && b == 0) { 20 | System.out.println("Undefined"); 21 | } else if (a == 0) { 22 | gcd = a; 23 | System.out.println("Undefined"); 24 | } else if (b == 0) { 25 | gcd = b; 26 | System.out.println("Undefined"); 27 | } else { 28 | while (b != 0) { 29 | t = b; 30 | b = a % b; 31 | a = t; 32 | } 33 | gcd = a; 34 | System.out.printf("LCM is %d\n", (x * y) / gcd); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Problem13.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem13 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner input = new Scanner(System.in); 10 | int T = input.nextInt(); 11 | 12 | while (T < 1 || T > 100) { 13 | T = input.nextInt(); 14 | } 15 | 16 | for (int i = 0; i < T; i++) { 17 | int n = input.nextInt(); 18 | int length = String.valueOf(n).length(); 19 | while (n < 0 || length > 100) { 20 | n = input.nextInt(); 21 | } 22 | System.out.println(evenodd(n)); 23 | } 24 | input.close(); 25 | } 26 | 27 | public static String evenodd(int n) { 28 | String result = ""; 29 | if (n % 2 == 0) { 30 | result = "even"; 31 | } else if (n % 2 != 0) { 32 | result = "odd"; 33 | } 34 | return result; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Palindrome.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Palindrome { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | String word; 10 | int i, j, len; 11 | boolean isPalindrome = false; 12 | Scanner scan = new Scanner(System.in); 13 | 14 | word = scan.next(); 15 | scan.close(); 16 | 17 | len = word.length(); 18 | j = len - 1; 19 | 20 | for (i = 0; i < len; i++, j--) { 21 | if (word.charAt(i) != word.charAt(j)) { 22 | isPalindrome = false; 23 | System.out.printf("%s is not a palindrome.\n", word); 24 | break; 25 | } else { 26 | isPalindrome = true; 27 | } 28 | if (i == j) { 29 | break; 30 | } 31 | } 32 | 33 | if (isPalindrome) { 34 | System.out.printf("%s is a palindrome.\n", word); 35 | } 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /অধ্যায় আট _ বাইনারি সার্চ/Program8_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program8_1 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 1, 4, 6, 8, 9, 11, 14, 15, 20, 25, 33, 83, 87, 97, 99, 100 }; 8 | int low_indx = 0; 9 | int high_indx = 15; 10 | int mid_indx = 0; 11 | int num = 97; 12 | 13 | while (low_indx <= high_indx) { 14 | mid_indx = (low_indx + high_indx) / 2; 15 | if (num == ara[mid_indx]) { 16 | break; 17 | } 18 | if (num < ara[mid_indx]) { 19 | high_indx = mid_indx - 1; 20 | } else { 21 | low_indx = mid_indx + 1; 22 | } 23 | } 24 | if (low_indx > high_indx) { 25 | System.out.printf("%d is not in the array\n", num); 26 | } else { 27 | System.out.printf("%d is found in the array. It is the %d th element of the array.\n", ara[mid_indx], 28 | mid_indx); 29 | } 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/Program13_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program13_1 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | 10 | String word, reverse_word; 11 | char[] reverse_array; 12 | int i, j, len; 13 | Scanner scan = new Scanner(System.in); 14 | 15 | word = scan.next(); 16 | scan.close(); 17 | 18 | len = word.length(); 19 | reverse_array = new char[len]; 20 | 21 | for (i = 0, j = len - 1; i < len; i++, j--) { 22 | reverse_array[i] = word.charAt(j); 23 | } 24 | 25 | reverse_word = String.valueOf(reverse_array); 26 | 27 | System.out.printf("%s\n", reverse_word); 28 | 29 | if (0 == word.compareTo(reverse_word)) { 30 | System.out.printf("%s is a palindrome.\n", word); 31 | } else { 32 | System.out.printf("%s is not a palindrome.\n", word); 33 | } 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Problem14.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem14 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner input = new Scanner(System.in); 10 | int T = input.nextInt(); 11 | 12 | while (T < 1 || T > 25) { 13 | T = input.nextInt(); 14 | } 15 | int[] allT = new int[T]; 16 | 17 | for (int i = 0; i < T; i++) { 18 | int n = input.nextInt(); 19 | while (n < 1 || n > 100) { 20 | n = input.nextInt(); 21 | } 22 | allT[i] = n; 23 | } 24 | input.close(); 25 | 26 | for (int i = 0; i < allT.length; i++) { 27 | drawSquare(allT[i]); 28 | System.out.println(); 29 | } 30 | 31 | } 32 | 33 | public static void drawSquare(int number) { 34 | for (int i = 0; i < number; i++) { 35 | for (int j = 0; j < number; j++) { 36 | System.out.print("*"); 37 | } 38 | System.out.println(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /অধ্যায় এগারো _ আবারও অ্যারে/Program11_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | //import java.util.Scanner; 4 | 5 | public class Program11_1 { 6 | public static void main(String[] args) { 7 | // TODO Auto-generated method stub 8 | int[][] marks = { { 80, 70, 92, 78, 58, 83, 85, 66, 99, 81 }, { 75, 67, 55, 100, 91, 84, 79, 61, 90, 97 }, 9 | { 98, 67, 75, 89, 81, 83, 80, 90, 88, 77 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; 10 | 11 | int col; 12 | 13 | for (col = 0; col < 10; col++) { 14 | marks[3][col] = (int) (marks[0][col] / 4.0 + marks[1][col] / 4.0 + marks[2][col] / 2.0); 15 | 16 | System.out.printf("Roll NO: %d Total Marks: %d\n", col + 1, marks[3][col]); 17 | } 18 | 19 | // to get inputs from user 20 | /* 21 | * Scanner scan = new Scanner(System.in); 22 | * 23 | * for (int i = 0; i < marks.length; i++) { for (int j = 0; j < 10; j++) { 24 | * marks[i][j] = scan.nextInt(); } } scan.close(); 25 | */ 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /অধ্যায় বারো _ বাইনারি সংখ্যা/DecimalToBinaryWayOne.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class DecimalToBinaryWayOne { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int decimal, n = 0, j = 0, sum = 0; 10 | char[] binaryArray; 11 | Scanner scan = new Scanner(System.in); 12 | 13 | System.out.printf("Enter the decimal number: "); 14 | decimal = scan.nextInt(); 15 | scan.close(); 16 | 17 | while (Math.pow(2, n) <= decimal) { 18 | n++; 19 | } 20 | 21 | binaryArray = new char[n]; 22 | 23 | for (int i = n - 1; i >= 0; i--) { 24 | if ((Math.pow(2, i) + sum) <= decimal) { 25 | sum = (int) (sum + Math.pow(2, i)); 26 | binaryArray[j] = '1'; 27 | j++; 28 | } else { 29 | binaryArray[j] = '0'; 30 | j++; 31 | } 32 | } 33 | 34 | System.out.printf("Binary value is %s\n", String.valueOf(binaryArray)); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_2 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double a1, a2, b1, b2, c1, c2, x, y; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("a1 = "); 13 | a1 = scan.nextDouble(); 14 | 15 | System.out.printf("a2 = "); 16 | a2 = scan.nextDouble(); 17 | 18 | System.out.printf("b1 = "); 19 | b1 = scan.nextDouble(); 20 | 21 | System.out.printf("b2 = "); 22 | b2 = scan.nextDouble(); 23 | 24 | System.out.printf("c1 = "); 25 | c1 = scan.nextDouble(); 26 | 27 | System.out.printf("c2 = "); 28 | c2 = scan.nextDouble(); 29 | scan.close(); 30 | 31 | x = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1); 32 | y = (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1); 33 | 34 | System.out.printf("x = %.2f, y = %.2f\n", x, y); 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /অধ্যায় এগারো _ আবারও অ্যারে/Program11_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program11_2 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int[][] namta = new int[10][10]; 8 | int row, col, evenCount = 0, oddCount = 0, sum = 0; 9 | 10 | for (row = 0; row < 10; row++) { 11 | for (col = 0; col < 10; col++) { 12 | namta[row][col] = (row + 1) * (col + 1); 13 | } 14 | } 15 | 16 | for (row = 0; row < 10; row++) { 17 | for (col = 0; col < 10; col++) { 18 | System.out.printf("%d x %d = %d\n", (row + 1), (col + 1), namta[row][col]); 19 | } 20 | System.out.printf("\n"); 21 | } 22 | 23 | for (row = 0; row < 10; row++) { 24 | for (col = 0; col < 10; col++) { 25 | if (namta[row][col] % 2 == 0) { 26 | evenCount++; 27 | } else { 28 | oddCount++; 29 | } 30 | 31 | sum = sum + namta[row][col]; 32 | } 33 | } 34 | System.out.printf("Odd count = %d, Even count = %d, Sum = %d\n", oddCount, evenCount, sum); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /অধ্যায় দুই _ ডেটা টাইপ, ইনপুট ও আউটপুট/Program2_15.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program2_15 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int num1, num2, value; 10 | char sign; 11 | Scanner scan = new Scanner(System.in); 12 | 13 | System.out.printf("Please enter a number: "); 14 | num1 = scan.nextInt(); 15 | 16 | System.out.printf("Please enter another number: "); 17 | num2 = scan.nextInt(); 18 | 19 | scan.close(); 20 | 21 | value = num1 + num2; 22 | sign = '+'; 23 | System.out.printf("%d %c %d = %d\n", num1, sign, num2, value); 24 | 25 | value = num1 - num2; 26 | sign = '-'; 27 | System.out.printf("%d %c %d = %d\n", num1, sign, num2, value); 28 | 29 | value = num1 * num2; 30 | sign = '*'; 31 | System.out.printf("%d %c %d = %d\n", num1, sign, num2, value); 32 | 33 | value = num1 / num2; 34 | sign = '/'; 35 | System.out.printf("%d %c %d = %d\n", num1, sign, num2, value); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_4.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_4 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double loan_amount, interest_rate, number_of_years, total_amount, monthly_amount, yearly_interest_amount; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("Enter the loan amount: "); 13 | loan_amount = scan.nextDouble(); 14 | 15 | System.out.printf("Enter the interest rate: "); 16 | interest_rate = scan.nextDouble(); 17 | 18 | System.out.printf("Number of years: "); 19 | number_of_years = scan.nextDouble(); 20 | scan.close(); 21 | 22 | yearly_interest_amount = loan_amount * interest_rate / 100.00; 23 | total_amount = loan_amount + yearly_interest_amount * number_of_years; 24 | monthly_amount = total_amount / (number_of_years * 12); 25 | 26 | System.out.printf("Total amount: %.2f\n", total_amount); 27 | System.out.printf("Monthly amount: %.2f\n", monthly_amount); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /অধ্যায় এগারো _ আবারও অ্যারে/Program11_6.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program11_6 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int[][] ara1 = { { 1, 2, 3, 4, 5 }, { 10, 20, 30, 40, 50 }, { 100, 200, 300, 400, 500 }, 8 | { 1000, 2000, 3000, 4000, 5000 }, { 10000, 20000, 30000, 40000, 50000 } }; 9 | int[][] ara2 = new int[5][5]; 10 | 11 | int r, c; 12 | 13 | System.out.printf("Content of first array (ara1): \n"); 14 | 15 | for (r = 0; r < 5; r++) { 16 | for (c = 0; c < 5; c++) { 17 | System.out.printf("%d ", ara1[r][c]); 18 | } 19 | 20 | System.out.printf("\n"); 21 | } 22 | 23 | System.out.printf("\n"); 24 | 25 | // now start copy 26 | for (r = 0; r < 5; r++) { 27 | for (c = 0; c < 5; c++) { 28 | ara2[c][r] = ara1[r][c]; 29 | } 30 | } 31 | 32 | System.out.printf("Content of second array (ara2): \n"); 33 | for (r = 0; r < 5; r++) { 34 | for (c = 0; c < 5; c++) { 35 | System.out.printf("%d ", ara2[r][c]); 36 | } 37 | System.out.printf("\n"); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /অধ্যায় দশ _ মৌলিক সংখ্যা/Program10_2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program10_2 { 6 | 7 | // smartest 8 | 9 | static int is_prime(int n) { 10 | int i, root; 11 | 12 | if (n < 2) { 13 | return 0; 14 | } 15 | 16 | if (n == 2) { 17 | return 1; 18 | } 19 | 20 | if (n % 2 == 0) { 21 | return 0; 22 | } 23 | 24 | root = (int) Math.sqrt(n); 25 | 26 | for (i = 3; i <= root; i += 2) { 27 | if (n % i == 0) { 28 | return 0; 29 | } 30 | } 31 | 32 | return 1; 33 | } 34 | 35 | public static void main(String[] args) { 36 | // TODO Auto-generated method stub 37 | int n; 38 | Scanner scan = new Scanner(System.in); 39 | while (true) { 40 | System.out.printf("Please enter a number (enter 0 to exit): "); 41 | n = scan.nextInt(); 42 | 43 | if (n == 0) { 44 | break; 45 | } 46 | 47 | if (1 == is_prime(n)) { 48 | System.out.printf("%d is a prime number.\n", n); 49 | } else { 50 | System.out.printf("%d is not a prime number.\n", n); 51 | } 52 | } 53 | 54 | scan.close(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /অধ্যায় পাঁচ _ একটুখানি গণিত/Program5_3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program5_3 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | double a1, a2, b1, b2, c1, c2, d, x, y; 10 | Scanner scan = new Scanner(System.in); 11 | 12 | System.out.printf("a1 = "); 13 | a1 = scan.nextDouble(); 14 | 15 | System.out.printf("a2 = "); 16 | a2 = scan.nextDouble(); 17 | 18 | System.out.printf("b1 = "); 19 | b1 = scan.nextDouble(); 20 | 21 | System.out.printf("b2 = "); 22 | b2 = scan.nextDouble(); 23 | 24 | System.out.printf("c1 = "); 25 | c1 = scan.nextDouble(); 26 | 27 | System.out.printf("c2 = "); 28 | c2 = scan.nextDouble(); 29 | scan.close(); 30 | 31 | d = a1 * b2 - a2 * b1; 32 | 33 | if ((int) d == 0) { 34 | System.out.printf("Value of x and y can not be determined.\n"); 35 | } else { 36 | x = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1); 37 | y = (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1); 38 | 39 | System.out.printf("x = %.2f, y = %.2f\n", x, y); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /অধ্যায় আট _ বাইনারি সার্চ/BinarySearch.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class BinarySearch { 4 | 5 | static int b_search(int ara[], int low, int high, int key) { 6 | int mid = 0; 7 | 8 | while (low <= high) { 9 | mid = (low + high) / 2; 10 | if (key == ara[mid]) { 11 | break; 12 | } 13 | if (key < ara[mid]) { 14 | high = mid - 1; 15 | } else { 16 | low = mid + 1; 17 | } 18 | } 19 | if (low > high) { 20 | return 0; 21 | } else { 22 | return mid; 23 | } 24 | } 25 | 26 | public static void main(String[] args) { 27 | // TODO Auto-generated method stub 28 | int ara[] = { 1, 4, 6, 8, 9, 11, 14, 15, 20, 25, 33, 83, 87, 97, 99, 100 }; 29 | int low_indx = 0; 30 | int high_indx = 15; 31 | int mid_indx = 0; 32 | int num = 97; 33 | 34 | mid_indx = b_search(ara, low_indx, high_indx, num); 35 | 36 | if (mid_indx == 0) { 37 | System.out.printf("%d is not in the array\n", num); 38 | } else { 39 | System.out.printf("%d is found in the array. It is the %d th element of the array.\n", ara[mid_indx], 40 | mid_indx); 41 | } 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /অধ্যায় ছয় _ অ্যারে/Program6_11.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program6_11 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ft_marks[] = { 83, 86, 97, 95, 93, 95, 86, 52, 49, 41, 42, 47, 90, 59, 63, 86, 40, 46, 92, 56, 51, 48, 67, 8 | 49, 42, 90, 42, 83, 47, 95, 69, 82, 82, 58, 69, 67, 53, 56, 71, 62 }, 9 | st_marks[] = { 86, 97, 95, 93, 95, 86, 52, 49, 41, 42, 47, 90, 59, 63, 86, 40, 46, 92, 56, 51, 48, 67, 10 | 49, 42, 90, 42, 83, 47, 95, 69, 82, 82, 58, 69, 67, 53, 56, 71, 62, 49 }, 11 | final_marks[] = { 87, 64, 91, 43, 89, 66, 58, 73, 99, 81, 100, 64, 55, 69, 85, 81, 80, 67, 88, 71, 62, 12 | 78, 58, 66, 98, 75, 86, 90, 80, 85, 100, 64, 55, 69, 85, 81, 80, 67, 88, 71 }; 13 | 14 | int i; 15 | double[] total_marks = new double[40]; 16 | 17 | for (i = 0; i < 40; i++) { 18 | total_marks[i] = ft_marks[i] / 4.0 + st_marks[i] / 4.0 + final_marks[i] / 2.0; 19 | } 20 | 21 | for (i = 1; i <= 40; i++) { 22 | System.out.printf("Roll NO: %d\tTotal Marks: %.0f\n", i, total_marks[i - 1]); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /অধ্যায় বারো _ বাইনারি সংখ্যা/DecimalToBinaryWayTwo.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.Scanner; 6 | 7 | public class DecimalToBinaryWayTwo { 8 | 9 | public static void main(String[] args) { 10 | // TODO Auto-generated method stub 11 | int decimal; 12 | Scanner scan = new Scanner(System.in); 13 | 14 | System.out.printf("Enter the decimal number: "); 15 | decimal = scan.nextInt(); 16 | scan.close(); 17 | 18 | System.out.printf("Binary value is %s\n", decimalToBinary(decimal)); 19 | 20 | } 21 | 22 | public static String decimalToBinary(int decimal) { 23 | ArrayList binaryList = new ArrayList(); 24 | 25 | int quotient = (int) (decimal / 2); 26 | int remainder = decimal % 2; 27 | 28 | while (quotient != 0) { 29 | binaryList.add(String.valueOf(remainder)); 30 | decimal = quotient; 31 | quotient = (int) (decimal / 2); 32 | remainder = decimal % 2; 33 | } 34 | binaryList.add(String.valueOf(decimal % 2)); 35 | 36 | Collections.reverse(binaryList); 37 | return String.join("", binaryList); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program9_5 { 6 | 7 | static int string_length(char str[]) { 8 | int length = 0; 9 | 10 | for (char c : str) { 11 | length++; 12 | } 13 | return length; 14 | } 15 | 16 | /* 17 | * we can also use this 18 | * static int string_length(char str[]) { 19 | * int length = 0; 20 | * 21 | * for (int i = 0; i < str.length; i++) { 22 | * length++; 23 | * } 24 | * 25 | * return length; 26 | * } 27 | */ 28 | 29 | /* 30 | * we can also use this 31 | * static int string_length(char str[]) { 32 | * int i; 33 | * 34 | * for (i = 0; i < str.length; i++); 35 | * return i; 36 | * } 37 | */ 38 | 39 | public static void main(String[] args) { 40 | // TODO Auto-generated method stub 41 | char[] country = new char[100]; 42 | Scanner scan = new Scanner(System.in); 43 | String str; 44 | 45 | int length; 46 | 47 | str = scan.nextLine(); 48 | scan.close(); 49 | country = str.toCharArray(); 50 | 51 | length = string_length(country); 52 | System.out.printf("length: %d\n", length); 53 | 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /অধ্যায় দশ _ মৌলিক সংখ্যা/Program10_1.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program10_1 { 6 | 7 | static int is_prime(int n) { 8 | int i; 9 | 10 | if (n < 2) { 11 | return 0; 12 | } 13 | 14 | for (i = 2; i < n; i++) { 15 | if (n % i == 0) { 16 | return 0; 17 | } 18 | } 19 | 20 | return 1; 21 | } 22 | 23 | // smarter 24 | /* 25 | * static int is_prime(int n) { int i; 26 | * 27 | * if (n < 2) { return 0; } 28 | * 29 | * if (n == 2) { return 1; } 30 | * 31 | * if (n % 2 == 0) { return 0; } 32 | * 33 | * for (i = 3; i <= n / 2; i += 2) { if (n % i == 0) { return 0; } } 34 | * 35 | * return 1; } 36 | */ 37 | 38 | public static void main(String[] args) { 39 | // TODO Auto-generated method stub 40 | int n; 41 | Scanner scan = new Scanner(System.in); 42 | while (true) { 43 | System.out.printf("Please enter a number (enter 0 to exit): "); 44 | n = scan.nextInt(); 45 | 46 | if (n == 0) { 47 | break; 48 | } 49 | 50 | if (1 == is_prime(n)) { 51 | System.out.printf("%d is a prime number.\n", n); 52 | } else { 53 | System.out.printf("%d is not a prime number.\n", n); 54 | } 55 | } 56 | 57 | scan.close(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/Program9_7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program9_7 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | // we can actually concatenate two strings like str1 + str2 in Java 8 | // we can also do it like the way it is shown in the book using C 9 | 10 | // Java way 11 | /* 12 | * String str1 = "bangla"; String str2 = "desh"; 13 | * 14 | * String str3 = str1 + str2; 15 | * 16 | * System.out.printf("%s\n", str3); 17 | */ 18 | 19 | // C way 20 | char[] str1 = { 'b', 'a', 'n', 'g', 'l', 'a' }, str2 = { 'd', 'e', 's', 'h' }, str3 = new char[12]; 21 | 22 | int i, j, length1 = 6, length2 = 4; 23 | 24 | for (i = 0, j = 0; i < length1; i++, j++) { 25 | str3[j] = str1[i]; 26 | } 27 | 28 | for (i = 0; i < length2; i++, j++) { 29 | str3[j] = str2[i]; 30 | } 31 | 32 | /* 33 | * Java doesn't "mark" the end-of-string as C does. It tracks length & values, 34 | * so it's possible to have zero-chars (\0) in the string. If we create a String 35 | * from a char array containing \0 chars, the resultant String will contain 36 | * those characters. 37 | */ 38 | 39 | System.out.printf("%s\n", String.valueOf(str3)); 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /অধ্যায় সাত _ ফাংশন/Program7_8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | public class Program7_8 { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | int ara[] = { 100, 0, 53, 22, 83, 23, 89, 132, 201, 3, 85 }; 8 | int n = 11; 9 | 10 | int max = find_max(ara, n); 11 | System.out.printf("%d\n", max); 12 | 13 | int min = find_min(ara, n); 14 | System.out.printf("%d\n", min); 15 | 16 | int sum = find_sum(ara, n); 17 | System.out.printf("%d\n", sum); 18 | 19 | double average = find_average(ara, n); 20 | System.out.printf("%.2f\n", average); 21 | } 22 | 23 | static int find_max(int ara[], int n) { 24 | int max = ara[0]; 25 | int i; 26 | for (i = 1; i < n; i++) { 27 | if (ara[i] > max) { 28 | max = ara[i]; 29 | } 30 | } 31 | return max; 32 | } 33 | 34 | static int find_min(int ara[], int n) { 35 | int min = ara[0]; 36 | int i; 37 | for (i = 1; i < n; i++) { 38 | if (ara[i] < min) { 39 | min = ara[i]; 40 | } 41 | } 42 | return min; 43 | } 44 | 45 | static int find_sum(int ara[], int n) { 46 | int sum = 0; 47 | int i; 48 | for (i = 0; i < n; i++) { 49 | sum += ara[i]; 50 | } 51 | return sum; 52 | } 53 | 54 | static double find_average(int ara[], int n) { 55 | int sum = find_sum(ara, n); 56 | 57 | return (double) sum / n; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/EncryptionProblem.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class EncryptionProblem { 6 | 7 | public static void encrypt(char msg[]) { 8 | int i, n; 9 | 10 | n = msg.length; 11 | 12 | for (i = 0; i < n; i++) { 13 | if ((msg[i] >= 'a' && msg[i] <= 'z') || (msg[i] >= 'A' && msg[i] <= 'Z')) { 14 | if (msg[i] == 'z') { 15 | msg[i] = 'a'; 16 | } else if (msg[i] == 'Z') { 17 | msg[i] = 'A'; 18 | } else { 19 | msg[i] = (char) (msg[i] + 1); 20 | } 21 | } 22 | } 23 | } 24 | 25 | public static void decrypt(char msg[]) { 26 | int i, n; 27 | 28 | n = msg.length; 29 | 30 | for (i = 0; i < n; i++) { 31 | if ((msg[i] >= 'a' && msg[i] <= 'z') || (msg[i] >= 'A' && msg[i] <= 'Z')) { 32 | if (msg[i] == 'a') { 33 | msg[i] = 'z'; 34 | } else if (msg[i] == 'A') { 35 | msg[i] = 'Z'; 36 | } else { 37 | msg[i] = (char) (msg[i] - 1); 38 | } 39 | } 40 | } 41 | } 42 | 43 | public static void main(String[] args) { 44 | // TODO Auto-generated method stub 45 | 46 | char[] s; 47 | Scanner scan = new Scanner(System.in); 48 | 49 | s = scan.nextLine().toCharArray(); 50 | scan.close(); 51 | 52 | encrypt(s); 53 | 54 | System.out.printf("%s\n", String.valueOf(s)); 55 | 56 | decrypt(s); 57 | 58 | System.out.printf("%s\n", String.valueOf(s)); 59 | 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Problem2.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem2 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | int[] numberCount; 11 | int N; 12 | String line; 13 | String[] numbersInALineStr; 14 | int[] numbersInALineStrInt; 15 | 16 | N = scan.nextInt(); 17 | scan.nextLine(); 18 | numberCount = new int[N]; 19 | 20 | for (int i = 0; i < N; i++) { 21 | line = scan.nextLine(); 22 | 23 | numbersInALineStr = line.trim().split("\\s+"); 24 | numbersInALineStrInt = new int[numbersInALineStr.length]; 25 | 26 | for (int j = 0; j < numbersInALineStr.length; j++) { 27 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 28 | } 29 | 30 | for (int number : numbersInALineStrInt) { 31 | while (Math.abs(number) > 10000000) { 32 | line = scan.nextLine(); 33 | 34 | numbersInALineStr = line.trim().split("\\s+"); 35 | numbersInALineStrInt = new int[numbersInALineStr.length]; 36 | 37 | for (int j = 0; j < numbersInALineStr.length; j++) { 38 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 39 | } 40 | } 41 | } 42 | numberCount[i] = numbersInALineStrInt.length; 43 | } 44 | scan.close(); 45 | 46 | for (int number : numberCount) { 47 | System.out.printf("%d\n", number); 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Problem3.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem3 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | int[] volume; 11 | int N; 12 | String line; 13 | String[] numbersInALineStr; 14 | int[] numbersInALineStrInt; 15 | 16 | N = scan.nextInt(); 17 | scan.nextLine(); 18 | volume = new int[N]; 19 | 20 | for (int i = 0; i < N; i++) { 21 | line = scan.nextLine(); 22 | int volumeIndividual = 1; 23 | 24 | numbersInALineStr = line.trim().split("\\s+"); 25 | numbersInALineStrInt = new int[numbersInALineStr.length]; 26 | 27 | for (int j = 0; j < numbersInALineStr.length; j++) { 28 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 29 | } 30 | 31 | for (int number : numbersInALineStrInt) { 32 | while (number < 1 || number > 100) { 33 | line = scan.nextLine(); 34 | 35 | numbersInALineStr = line.trim().split("\\s+"); 36 | numbersInALineStrInt = new int[numbersInALineStr.length]; 37 | 38 | for (int j = 0; j < numbersInALineStr.length; j++) { 39 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 40 | } 41 | } 42 | } 43 | 44 | for (int j = 0; j < 3; j++) { 45 | volumeIndividual = volumeIndividual * numbersInALineStrInt[j]; 46 | } 47 | 48 | volume[i] = volumeIndividual; 49 | } 50 | scan.close(); 51 | 52 | for (int number : volume) { 53 | System.out.printf("%d\n", number); 54 | } 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Problem7.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem7 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | int[] average; 11 | int N, sum; 12 | String line; 13 | String[] numbersInALineStr; 14 | int[] numbersInALineStrInt; 15 | 16 | N = scan.nextInt(); 17 | scan.nextLine(); 18 | average = new int[N]; 19 | 20 | for (int i = 0; i < N; i++) { 21 | line = scan.nextLine(); 22 | sum = 0; 23 | 24 | numbersInALineStr = line.trim().split("\\s+"); 25 | numbersInALineStrInt = new int[numbersInALineStr.length]; 26 | 27 | for (int j = 0; j < numbersInALineStr.length; j++) { 28 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 29 | } 30 | 31 | for (int number : numbersInALineStrInt) { 32 | while (number < 0 || number > 100) { 33 | line = scan.nextLine(); 34 | 35 | numbersInALineStr = line.trim().split("\\s+"); 36 | numbersInALineStrInt = new int[numbersInALineStr.length]; 37 | 38 | for (int j = 0; j < numbersInALineStr.length; j++) { 39 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 40 | } 41 | } 42 | } 43 | 44 | for (int j = 0; j < numbersInALineStrInt.length; j++) { 45 | sum = sum + numbersInALineStrInt[j]; 46 | } 47 | 48 | average[i] = sum / 5; 49 | } 50 | scan.close(); 51 | 52 | for (int i = 0; i < average.length; i++) { 53 | System.out.printf("%d\n", average[i]); 54 | } 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Problem8.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem8 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner scan = new Scanner(System.in); 10 | double[] average; 11 | int N, sum; 12 | String line; 13 | String[] numbersInALineStr; 14 | int[] numbersInALineStrInt; 15 | 16 | N = scan.nextInt(); 17 | scan.nextLine(); 18 | average = new double[N]; 19 | 20 | for (int i = 0; i < N; i++) { 21 | line = scan.nextLine(); 22 | sum = 0; 23 | 24 | numbersInALineStr = line.trim().split("\\s+"); 25 | numbersInALineStrInt = new int[numbersInALineStr.length]; 26 | 27 | for (int j = 0; j < numbersInALineStr.length; j++) { 28 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 29 | } 30 | 31 | for (int number : numbersInALineStrInt) { 32 | while (number < 0 || number > 100) { 33 | line = scan.nextLine(); 34 | 35 | numbersInALineStr = line.trim().split("\\s+"); 36 | numbersInALineStrInt = new int[numbersInALineStr.length]; 37 | 38 | for (int j = 0; j < numbersInALineStr.length; j++) { 39 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 40 | } 41 | } 42 | } 43 | 44 | for (int j = 1; j <= numbersInALineStrInt[0]; j++) { 45 | sum = sum + numbersInALineStrInt[j]; 46 | } 47 | 48 | average[i] = (double) sum / numbersInALineStrInt[0]; 49 | } 50 | scan.close(); 51 | 52 | for (int i = 0; i < average.length; i++) { 53 | System.out.printf("%.2f\n", average[i]); 54 | } 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Problem11.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem11 { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | Scanner input = new Scanner(System.in); 10 | int T = input.nextInt(); 11 | 12 | while (T < 1) { 13 | T = input.nextInt(); 14 | } 15 | input.nextLine(); 16 | String[] inputs = new String[T]; 17 | 18 | for (int i = 0; i < inputs.length; i++) { 19 | String temp = input.nextLine(); 20 | int length = temp.length(); 21 | while (length > 50 || !isDigit(temp.charAt(0)) || !isDigit(temp.charAt(temp.length() - 1)) 22 | || !isValid(temp)) { 23 | temp = input.nextLine(); 24 | length = temp.length(); 25 | } 26 | inputs[i] = temp; 27 | } 28 | input.close(); 29 | 30 | for (int i = 0; i < inputs.length; i++) { 31 | StringBuilder myString = new StringBuilder(inputs[i]); 32 | 33 | for (int j = 1; j < myString.length() - 1; j++) { 34 | if (myString.charAt(j) == 'R') { 35 | 36 | myString.setCharAt(j, myString.charAt(j + 1)); 37 | } else if (myString.charAt(j) == 'L') { 38 | myString.setCharAt(j, myString.charAt(j - 1)); 39 | } 40 | } 41 | System.out.println(myString); 42 | } 43 | 44 | } 45 | 46 | static boolean isDigit(char m) { 47 | if (m >= 48 && m <= 57) { 48 | return true; 49 | } else { 50 | return false; 51 | } 52 | } 53 | 54 | static boolean isValid(String s) { 55 | boolean res = true; 56 | for (int i = 1; i < s.length() - 1; i++) { 57 | if (s.charAt(i) == 'R' || s.charAt(i) == 'L') { 58 | if (isDigit(s.charAt(i - 1)) && isDigit(s.charAt(i + 1))) { 59 | res = true; 60 | } else { 61 | res = false; 62 | return res; 63 | } 64 | } 65 | } 66 | return res; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /Problem9.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem9 { 6 | 7 | static int is_prime(int n) { 8 | int i, root; 9 | 10 | if (n < 2) { 11 | return 0; 12 | } 13 | 14 | if (n == 2) { 15 | return 1; 16 | } 17 | 18 | if (n % 2 == 0) { 19 | return 0; 20 | } 21 | 22 | root = (int) Math.sqrt(n); 23 | 24 | for (i = 3; i <= root; i += 2) { 25 | if (n % i == 0) { 26 | return 0; 27 | } 28 | } 29 | 30 | return 1; 31 | } 32 | 33 | public static void main(String[] args) { 34 | // TODO Auto-generated method stub 35 | Scanner scan = new Scanner(System.in); 36 | int[] primeCount; 37 | int N; 38 | String line; 39 | String[] numbersInALineStr; 40 | int[] numbersInALineStrInt; 41 | 42 | N = scan.nextInt(); 43 | scan.nextLine(); 44 | primeCount = new int[N]; 45 | 46 | for (int i = 0; i < N; i++) { 47 | line = scan.nextLine(); 48 | int individualPrimeCount = 0; 49 | 50 | numbersInALineStr = line.trim().split("\\s+"); 51 | numbersInALineStrInt = new int[numbersInALineStr.length]; 52 | 53 | for (int j = 0; j < numbersInALineStr.length; j++) { 54 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 55 | } 56 | 57 | for (int number : numbersInALineStrInt) { 58 | while (number < 0 || number > 100) { 59 | line = scan.nextLine(); 60 | 61 | numbersInALineStr = line.trim().split("\\s+"); 62 | numbersInALineStrInt = new int[numbersInALineStr.length]; 63 | 64 | for (int j = 0; j < numbersInALineStr.length; j++) { 65 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 66 | } 67 | } 68 | } 69 | 70 | for (int j = 0; j < 10; j++) { 71 | if (is_prime(numbersInALineStrInt[j]) == 1) { 72 | individualPrimeCount++; 73 | } 74 | } 75 | 76 | primeCount[i] = individualPrimeCount; 77 | } 78 | scan.close(); 79 | 80 | for (int i = 0; i < primeCount.length; i++) { 81 | System.out.printf("%d\n", primeCount[i]); 82 | } 83 | 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /Problem5.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Problem5 { 6 | 7 | public static int getMax(int[] inputArray) { 8 | int maxValue = inputArray[0]; 9 | 10 | for (int i = 1; i < inputArray.length; i++) { 11 | if (inputArray[i] > maxValue) { 12 | maxValue = inputArray[i]; 13 | } 14 | } 15 | return maxValue; 16 | } 17 | 18 | public static int getMin(int[] inputArray) { 19 | int minValue = inputArray[0]; 20 | 21 | for (int i = 1; i < inputArray.length; i++) { 22 | if (inputArray[i] < minValue) { 23 | minValue = inputArray[i]; 24 | } 25 | } 26 | return minValue; 27 | } 28 | 29 | public static void main(String[] args) { 30 | // TODO Auto-generated method stub 31 | Scanner scan = new Scanner(System.in); 32 | int[][] maxMin; 33 | int N; 34 | String line; 35 | String[] numbersInALineStr; 36 | int[] numbersInALineStrInt; 37 | 38 | N = scan.nextInt(); 39 | scan.nextLine(); 40 | maxMin = new int[N][2]; 41 | 42 | for (int i = 0; i < N; i++) { 43 | line = scan.nextLine(); 44 | 45 | numbersInALineStr = line.trim().split("\\s+"); 46 | numbersInALineStrInt = new int[numbersInALineStr.length]; 47 | 48 | for (int j = 0; j < numbersInALineStr.length; j++) { 49 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 50 | } 51 | 52 | for (int number : numbersInALineStrInt) { 53 | while (number < 0 || number > 100) { 54 | line = scan.nextLine(); 55 | 56 | numbersInALineStr = line.trim().split("\\s+"); 57 | numbersInALineStrInt = new int[numbersInALineStr.length]; 58 | 59 | for (int j = 0; j < numbersInALineStr.length; j++) { 60 | numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]); 61 | } 62 | } 63 | } 64 | 65 | maxMin[i][0] = getMax(numbersInALineStrInt); 66 | maxMin[i][1] = getMin(numbersInALineStrInt); 67 | } 68 | scan.close(); 69 | 70 | for (int i = 0; i < maxMin.length; i++) { 71 | System.out.printf("%d %d\n", maxMin[i][0], maxMin[i][1]); 72 | } 73 | 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /অধ্যায় নয় _ স্ট্রিং (string)/StringCompare.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Objects; 4 | 5 | public class StringCompare { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | // there are many built in methods and ways to compare strings in Java, let's 10 | // check them first. 11 | // later we will implement our own string_compare method 12 | 13 | String a = "aaa"; 14 | String b = "aaa"; 15 | String c = new String("aAa"); 16 | String d = new String("aaa"); 17 | String e = new String("aa"); 18 | String f = new String("aaa"); 19 | 20 | System.out.println(a.equals(c)); // false 21 | System.out.println(a.equals(b)); // true 22 | System.out.println(a.equals(d)); // true 23 | 24 | System.out.println(a.equalsIgnoreCase(c)); // true 25 | 26 | System.out.println(a == b); // true, because both refer to same instance 27 | System.out.println(a == d); // false, because d refers to instance created in non pool 28 | 29 | System.out.println(a.compareTo(b)); // 0, because a == b 30 | System.out.println(b.compareTo(d)); // 0, because b == d 31 | System.out.println(a.compareTo(e)); // 1, because a > e 32 | System.out.println(e.compareTo(a)); // -1, because e < a 33 | 34 | System.out.println(Objects.equals(d, f)); // true 35 | System.out.println(Objects.equals(d, c)); // false 36 | System.out.println(Objects.equals(d, e)); // false 37 | System.out.println(Objects.equals(a, b)); // true 38 | 39 | // our own compare method 40 | System.out.println(string_compare(a.toCharArray(), b.toCharArray())); // 0, because a == b 41 | System.out.println(string_compare(a.toCharArray(), e.toCharArray())); // 1, because a > e 42 | System.out.println(string_compare(e.toCharArray(), a.toCharArray())); // -1, because e < a 43 | System.out.println(string_compare(c.toCharArray(), a.toCharArray())); // -1, comparing the ASCII value 44 | 45 | } 46 | 47 | static int string_compare(char a[], char b[]) { 48 | 49 | int i, val = 0; 50 | 51 | for (i = 0; i < a.length && i < b.length; i++) { 52 | if (a[i] < b[i]) { 53 | return -1; 54 | } 55 | if (a[i] > b[i]) { 56 | return 1; 57 | } 58 | } 59 | 60 | if (a.length == b.length) { 61 | val = 0; 62 | } 63 | 64 | if (a.length < b.length) { 65 | val = -1; 66 | } 67 | 68 | if (a.length > b.length) { 69 | val = 1; 70 | } 71 | return val; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Problem16.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.Scanner; 6 | 7 | public class Problem16 { 8 | 9 | public static int getFactorial(int number) { 10 | int factorial = 1; 11 | 12 | if (number == 0 || number == 1) { 13 | return factorial; 14 | } else { 15 | for (int i = number; i >= 1; i--) { 16 | factorial = factorial * i; 17 | } 18 | return factorial; 19 | } 20 | } 21 | 22 | public static void main(String[] args) { 23 | // TODO Auto-generated method stub 24 | Scanner input = new Scanner(System.in); 25 | String line; 26 | int lineLength; 27 | String[] lineInArray; 28 | String[] lines; 29 | 30 | int N = input.nextInt(); 31 | 32 | while (N < 1) { 33 | N = input.nextInt(); 34 | } 35 | 36 | lines = new String[N]; 37 | 38 | for (int i = 0; i < N; i++) { 39 | line = input.nextLine(); 40 | 41 | lineLength = line.trim().split("\\s+").length; 42 | lineInArray = line.trim().split("\\s+"); 43 | 44 | boolean allFine = true; 45 | 46 | for (String word : lineInArray) { 47 | if (word.length() < 1 || word.length() > 20) { 48 | allFine = false; 49 | break; 50 | } 51 | } 52 | 53 | while (lineLength < 1 || lineLength > 10 || allFine == false) { 54 | line = input.nextLine(); 55 | 56 | lineLength = line.trim().split("\\s+").length; 57 | lineInArray = line.trim().split("\\s+"); 58 | 59 | allFine = true; 60 | 61 | for (String word : lineInArray) { 62 | if (word.length() < 1 || word.length() > 20) { 63 | allFine = false; 64 | break; 65 | } 66 | } 67 | 68 | } 69 | lines[i] = line; 70 | 71 | } 72 | input.close(); 73 | 74 | for (int i = 0; i < lines.length; i++) { 75 | ArrayList wordsList = new ArrayList(); 76 | lineInArray = lines[i].trim().split("\\s+"); 77 | 78 | for (String word : lineInArray) { 79 | wordsList.add(word); 80 | } 81 | int denominator = 1; 82 | 83 | for (int j = 0; j < wordsList.size();) { 84 | 85 | int counter = 0; 86 | for (int j2 = 0; j2 < lineInArray.length; j2++) { 87 | if (wordsList.get(j).equals(lineInArray[j2])) { 88 | counter++; 89 | } 90 | } 91 | denominator = denominator * getFactorial(counter); 92 | wordsList.removeAll(Collections.singleton(wordsList.get(j))); 93 | } 94 | 95 | int n = getFactorial(lines[i].trim().split("\\s+").length) / denominator; 96 | System.out.printf("1/%d\n", n); 97 | } 98 | 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /Problem15.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | public class Problem15 { 7 | 8 | public static String removeDuplicateElements(int[] arrayWithDuplicates) { 9 | int size = arrayWithDuplicates.length; 10 | String result = ""; 11 | 12 | for (int i = 0; i < size; i++) { 13 | for (int j = i + 1; j < size; j++) { 14 | if (arrayWithDuplicates[i] == arrayWithDuplicates[j]) { 15 | arrayWithDuplicates[j] = arrayWithDuplicates[size - 1]; 16 | size--; 17 | j--; 18 | } 19 | } 20 | } 21 | 22 | int[] arrayWithNoDuplicates = Arrays.copyOf(arrayWithDuplicates, size); 23 | 24 | for (int i = 0; i < arrayWithNoDuplicates.length; i++) { 25 | result = result + String.valueOf(arrayWithNoDuplicates[i]); 26 | } 27 | 28 | return result; 29 | } 30 | 31 | static String getDistinct(int arr[], int n) { 32 | Arrays.sort(arr); 33 | String res = ""; 34 | 35 | for (int i = 0; i < n; i++) { 36 | while (i < n - 1 && arr[i] == arr[i + 1]) 37 | i++; 38 | 39 | res = res + Integer.toString(arr[i]); 40 | } 41 | return res; 42 | } 43 | 44 | public static void main(String[] args) { 45 | // TODO Auto-generated method stub 46 | Scanner input = new Scanner(System.in); 47 | int firstNumber, secondNumber; 48 | String firstNumberStr, secondNumberStr; 49 | String[] results; 50 | String result; 51 | 52 | int T = input.nextInt(); 53 | 54 | while (T < 1) { 55 | T = input.nextInt(); 56 | } 57 | results = new String[T]; 58 | 59 | for (int i = 0; i < T; i++) { 60 | firstNumber = input.nextInt(); 61 | 62 | while (Integer.toString(firstNumber).length() != 2) { 63 | firstNumber = input.nextInt(); 64 | } 65 | 66 | secondNumber = input.nextInt(); 67 | 68 | while (Integer.toString(secondNumber).length() != 2) { 69 | secondNumber = input.nextInt(); 70 | } 71 | 72 | firstNumberStr = Integer.toString(firstNumber); 73 | secondNumberStr = Integer.toString(secondNumber); 74 | 75 | result = ""; 76 | 77 | for (int j = 0; j < firstNumberStr.length(); j++) { 78 | for (int j2 = 0; j2 < secondNumberStr.length(); j2++) { 79 | if (firstNumberStr.charAt(j) == secondNumberStr.charAt(j2)) { 80 | result = result + firstNumberStr.charAt(j); 81 | break; 82 | } 83 | } 84 | } 85 | if (result == "") { 86 | results[i] = "N"; 87 | } else { 88 | char[] a = result.toCharArray(); 89 | Arrays.sort(a); 90 | int[] aInteger = new int[a.length]; 91 | 92 | for (int j = 0; j < a.length; j++) { 93 | aInteger[j] = Integer.parseInt(String.valueOf(a[j])); 94 | } 95 | 96 | results[i] = removeDuplicateElements(aInteger); 97 | } 98 | 99 | } 100 | input.close(); 101 | 102 | for (String res : results) { 103 | System.out.printf("%s\n", res); 104 | } 105 | 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /অধ্যায় তেরো _ কিছু প্রোগ্রামিং সমস্যা/GridTraversalProblem.java: -------------------------------------------------------------------------------- 1 | package ComputerProgrammingPartOne; 2 | 3 | import java.util.Scanner; 4 | 5 | public class GridTraversalProblem { 6 | 7 | public static void main(String[] args) { 8 | // TODO Auto-generated method stub 9 | int[][] grid = new int[10][10]; 10 | Scanner scan = new Scanner(System.in); 11 | int n, x, y; 12 | char c; 13 | 14 | for (int i = 0; i < 10; i++) { 15 | for (int j = 0; j < 10; j++) { 16 | grid[i][j] = 1; 17 | } 18 | } 19 | 20 | System.out.printf("Please enter the number of blocked cells: "); 21 | n = scan.nextInt(); 22 | 23 | while (n < 0 || n > 100) { 24 | System.out.printf("Blocked cells number exceeds the capacity! Enter again: "); 25 | n = scan.nextInt(); 26 | 27 | } 28 | 29 | if (n != 0) { 30 | System.out.printf("Now enter the cells: "); 31 | 32 | for (int i = 0; i < n; i++) { 33 | x = scan.nextInt(); 34 | y = scan.nextInt(); 35 | 36 | while (x < 0 || y < 0 || x > 9 || y > 9) { 37 | System.out.printf("Error! Index out of bound. Enter again: "); 38 | x = scan.nextInt(); 39 | y = scan.nextInt(); 40 | } 41 | grid[x][y] = 0; 42 | } 43 | } 44 | 45 | if (n == 100) { 46 | System.out.printf("All cells blocked! Can't land anywhere! Program stops."); 47 | System.exit(0); 48 | } 49 | 50 | System.out.printf("Please enter the initial position: "); 51 | x = scan.nextInt(); 52 | y = scan.nextInt(); 53 | 54 | while (x < 0 || y < 0 || x > 9 || y > 9) { 55 | System.out.printf("Error! Index out of bound. Enter again: "); 56 | x = scan.nextInt(); 57 | y = scan.nextInt(); 58 | } 59 | 60 | while (grid[x][y] == 0) { 61 | System.out.printf("Cell %d, %d is blocked. Can't land here! Enter again: ", x, y); 62 | x = scan.nextInt(); 63 | y = scan.nextInt(); 64 | } 65 | 66 | System.out.printf("Now, please enter your choice. U (up), D (down), L (left), R (right), S (stop): "); 67 | 68 | while (true) { 69 | c = scan.next().charAt(0); 70 | 71 | if (c == 'S') { 72 | break; 73 | } else if (c == 'U') { 74 | x--; 75 | if (x < 0) { 76 | System.out.printf("Cant' move up anymore, stuck on the wall!\n"); 77 | x++; 78 | continue; 79 | } 80 | 81 | if (grid[x][y] == 1) { 82 | System.out.printf("Moved 1 grid up. Moved to (%d, %d)\n", x, y); 83 | } else if (grid[x][y] == 0) { 84 | System.out.printf("Cant' move up! Cell (%d, %d) is blocked!\n", x, y); 85 | x++; 86 | } 87 | } else if (c == 'D') { 88 | x++; 89 | if (x > 9) { 90 | System.out.printf("Cant' move down anymore, stuck on the wall!\n"); 91 | x--; 92 | continue; 93 | } 94 | 95 | if (grid[x][y] == 1) { 96 | System.out.printf("Moved 1 grid down. Moved to (%d, %d)\n", x, y); 97 | } else if (grid[x][y] == 0) { 98 | System.out.printf("Cant' move down! Cell (%d, %d) is blocked!\n", x, y); 99 | x--; 100 | } 101 | } else if (c == 'R') { 102 | y++; 103 | if (y > 9) { 104 | System.out.printf("Cant' move right anymore, stuck on the wall!\n"); 105 | y--; 106 | continue; 107 | } 108 | 109 | if (grid[x][y] == 1) { 110 | System.out.printf("Moved 1 grid right. Moved to (%d, %d)\n", x, y); 111 | } else if (grid[x][y] == 0) { 112 | System.out.printf("Cant' move right! Cell (%d, %d) is blocked!\n", x, y); 113 | y--; 114 | } 115 | } else if (c == 'L') { 116 | y--; 117 | if (y < 0) { 118 | System.out.printf("Cant' move left anymore, stuck on the wall!\n"); 119 | y++; 120 | continue; 121 | } 122 | 123 | if (grid[x][y] == 1) { 124 | System.out.printf("Moved 1 grid left. Moved to (%d, %d)\n", x, y); 125 | } else if (grid[x][y] == 0) { 126 | System.out.printf("Cant' move left! Cell (%d, %d) is blocked!\n", x, y); 127 | y++; 128 | } 129 | } 130 | } 131 | 132 | scan.close(); 133 | System.out.printf("Final position of the robot is: (%d, %d)\n", x, y); 134 | 135 | } 136 | 137 | } 138 | --------------------------------------------------------------------------------