এই নিবন্ধে, আমরা বুঝব কিভাবে একটি বর্গক্ষেত্রের ক্ষেত্রফল বের করতে হয়। নিম্নলিখিত সূত্র -
ব্যবহার করে একটি বর্গক্ষেত্রের ক্ষেত্রফল গণনা করা হয়side*side i.e. s2
নীচে একই -
এর একটি প্রদর্শন রয়েছে৷একটি বর্গক্ষেত্রের বাহু s হলে, বর্গক্ষেত্রের ক্ষেত্রফল s 2 দ্বারা দেওয়া হয় −

ইনপুট
ধরুন আমাদের ইনপুট হল −
Length of the side : 4
আউটপুট
কাঙ্খিত আউটপুট হবে −
Area of the square : 16
অ্যালগরিদম
Step 1 - START Step 2 - Declare 2 integer values namely my_side and my_area. Step 3 - Read the required values from the user/ define the values. Step 4 – Calculate the area of the square using the formula side*side and store the result Step 5- Display the result Step 6- Stop
উদাহরণ 1
এখানে, একটি প্রম্পটের উপর ভিত্তি করে ব্যবহারকারী দ্বারা ইনপুট প্রবেশ করানো হচ্ছে। আপনি আমাদের কোডিং গ্রাউন্ড টুলে এই উদাহরণ লাইভ চেষ্টা করতে পারেন
।
import java.util.Scanner;
public class AreaOfSquare {
public static void main(String args[]){
int my_side, my_area;
System.out.println("Required packages have been imported");
Scanner my_scanner = new Scanner(System.in);
System.out.println("A reader object has been defined ");
System.out.print("Enter the length of a side : ");
my_side = my_scanner.nextInt();
my_area = my_side* my_side;
System.out.println("The my_area of the square is :"+my_area);
}
} আউটপুট
Required packages have been imported A reader object has been defined Enter the length of a side : 4 The area of the square is :16
উদাহরণ 2
এখানে, পূর্ণসংখ্যা পূর্বে সংজ্ঞায়িত করা হয়েছে, এবং এর মান অ্যাক্সেস করা হয়েছে এবং কনসোলে প্রদর্শিত হয়েছে।
public class AreaOfSquare {
public static void main(String args[]){
int my_side, my_area;
my_side = 4;
System.out.println("The length of the side of the square is defined as : " +my_side);
my_area = my_side* my_side;
System.out.println("The my_area of the square is :"+my_area);
}
} আউটপুট
The length of the side of the square is defined as : 4 The area of the square is :16