কোডজিম ইউনিভার্সিটি কোর্সের অংশ হিসাবে একজন পরামর্শদাতার সাথে একটি বক্তৃতা স্নিপেট। সম্পূর্ণ কোর্সের জন্য সাইন আপ করুন।


"হাই, অ্যামিগো। আজ আমরা যদি/অন্যথার বিবৃতি নিয়ে কথা বলব ।"

"প্রোগ্রামগুলি খুব কমই কাজে লাগবে যদি তারা বাহ্যিক পরিস্থিতির পরিবর্তনের সাথে সাড়া না দেয়। একটি প্রোগ্রামকে জানতে হবে কিভাবে পরিস্থিতির সাথে খাপ খাইয়ে নিতে হয় এবং একটি ক্ষেত্রে একটি ক্রিয়া এবং অন্য ক্ষেত্রে অন্য ক্রিয়াগুলি সম্পাদন করতে হয়। জাভাতে, এটি ব্যবহার করে অর্জন করা হয় 'যদি/অন্যথা বিবৃতি' - একটি বিশেষ গঠন যা একটি শর্ত সন্তুষ্ট হলে বিভিন্ন কোড ব্লক সম্পাদন করা সম্ভব করে।"

"এটি তিনটি অংশ নিয়ে গঠিত: ' শর্ত ', ' কমান্ড 1 ' এবং ' কমান্ড 2 '৷ যদি শর্তটি সত্য হয় তবে ' কমান্ড 1 ' কার্যকর করা হয়, অন্যথায় ' কমান্ড 2 ' কার্যকর করা হয়৷ এই কমান্ডগুলি কখনই কার্যকর করা হয় না৷ বিবৃতিটি কমবেশি এইরকম দেখায়:"

একটি if/else বিবৃতির জন্য কোড
if (condition)
    command_1;
else
    command_2;

"কত উত্তেজনাপূর্ণ! আমি মনে করি এই বিবৃতিটি প্রোগ্রামিংকে আরও আকর্ষণীয় করে তুলবে!"

"হ্যাঁ। এখানে আপনার জন্য কয়েকটি উদাহরণ দেওয়া হল:"

কোড ব্যাখ্যা
1
if (a < b)
    System.out.println("A is less than B");
else
    System.out.println("B is less than  A");
a যদি b এর থেকে কম হয়, প্রথম কমান্ডটি কার্যকর করা হবে। অন্যথায় দ্বিতীয় কমান্ডটি কার্যকর করা হবেকমান্ড উভয়ই কার্যকর হয় না।
2
if (a < b)
{
    System.out.println("A is less than B");
    System.out.println("B is greater than A");
}
else
{
     System.out.println("B is less than A");
     System.out.println("A is greater than B");
}
আপনি একটি কোড ব্লক দিয়ে একটি কমান্ড প্রতিস্থাপন করতে পারেন। বাকি একই।
3
if (a < b)
{
    a = 0;
}
else
{
}
আপনি অন্য ব্লকটি বাদ দিতে পারেন যদি এটি খালি থাকে।
এই তিনটি উদাহরণ সম্পূর্ণ সমতুল্য।
আপনি কোঁকড়া বন্ধনী বাদ দিতে পারেন যদি আপনাকে শুধুমাত্র একটি কমান্ড চালানোর প্রয়োজন হয়। আপনার যদি একাধিক কমান্ড থাকে তবে আপনাকে বন্ধনীগুলি রাখতে হবে।
4
if (a < b)
{
    a = 0;
}
5
if (a < b)
    a = 0;

"ডিয়েগো আমাকে শুধু তোমাকে কয়েকটি কাজ দিতে বলেছে।"

2
কাজ
Java Syntax,  লেভেল 4পাঠ 4
লক করা আছে
Good or bad?
Student robot Peter is an overachiever. Previously, his server was configured to receive scores on a five-point scale, but now his teachers have switched to a 12-point scale. But Peter doesn't know this. He's still focused on getting fives. Let's write him a compare method that compares any number with five.
4
কাজ
Java Syntax,  লেভেল 4পাঠ 4
লক করা আছে
Closest to 10
Ten is extremely popular and attractive number. Everyone wants to be a ten. Or at least as close to it as possible. Two numbers are standing around wondering which of them is cooler. Answer: whichever is closer to ten. Let's write these numbers a displayClosestToTen method that will determine which of them is cooler.
4
কাজ
Java Syntax,  লেভেল 4পাঠ 4
লক করা আছে
Come on, lucky seven!
Dice games are popular on the planet Foggy Multidimensions. The rules are different than the Earth version: Multidimensionals perceive far more dimensions than primitive three-dimensional earthlings. Their die has 4294967295 faces. Players win only if they roll a number between 50 and 100. We'll write a method that checks whether the die roll is in this range.
4
কাজ
Java Syntax,  লেভেল 4পাঠ 4
লক করা আছে
Seasons on Terra
An Earth year consists of four seasons, each of which lasts 3 months. While our ship was parked on this cradle of humanity, the Interplanetary Tax Service asked us to write a program to determine the season based on a number corresponding to the month of the year. We don't know why they want it. They say that it's none of our business. But they promised not to remain in our debt.
4
কাজ
Java Syntax,  লেভেল 4পাঠ 4
লক করা আছে
Positive and negative numbers
Diego is tall, but Alfredo is short. Rishi is experienced, but you're a "noob" programmer. Comparisons are unavoidable in life. And the same thing is true in programs. So we'll continue practicing comparisons and displaying stuff on the screen. This time let's compare the entered number with zero and manipulate it based on the result of the comparison.
4
কাজ
Java Syntax,  লেভেল 4পাঠ 4
লক করা আছে
Day of the week
Planet Terra still has "offices"—an outdated type of workspace. With current technology, there is no need for them, but earthlings tend to be nostalgic and haven't been in a hurry to eradicate them. Terrestrial office workers develop "TGIF syndrome": they constantly want to know what day of the week it is. Let's write a program for them!

কোডজিম ইউনিভার্সিটি কোর্সের অংশ হিসাবে একজন পরামর্শদাতার সাথে একটি বক্তৃতা স্নিপেট। সম্পূর্ণ কোর্সের জন্য সাইন আপ করুন।