এই নিবন্ধে, আমরা বুঝতে পারব কিভাবে দুটি ভাসমান-বিন্দু সংখ্যাকে গুণ করতে হয়। ফ্লোটিং পয়েন্ট সংখ্যা হল দশমিক মানের সংখ্যা। ফ্লোট ডেটা টাইপ হল একটি একক-নির্ভুলতা 32-বিট IEEE 754 ফ্লোটিং পয়েন্ট। এটি প্রধানত ফ্লোটিং-পয়েন্ট সংখ্যার বড় অ্যারেতে মেমরি সংরক্ষণ করতে ব্যবহৃত হয়। ডিফল্ট মান হল 0.0f. ফ্লোট ডেটা টাইপ কখনই মুদ্রার মতো সুনির্দিষ্ট মানগুলির জন্য ব্যবহার করা হয় না।
নীচে একই -
এর একটি প্রদর্শন রয়েছে৷ইনপুট
ধরুন আমাদের ইনপুট হল −
Value_1: 12.4f Value_2: 15.7f
আউটপুট
কাঙ্খিত আউটপুট হবে −
Result : 194.68f
অ্যালগরিদম
Step 1- Start Step 2- Declare three floating points: input_1, input_2 and product Step 3- Prompt the user to enter two floating point value/ define the floating-point values Step 4- Read the values Step 5- Multiply the two values using a multiplication operator (*) Step 6- Display the result Step 7- Stop
উদাহরণ 1
এখানে, একটি প্রম্পটের উপর ভিত্তি করে ব্যবহারকারী দ্বারা ইনপুট প্রবেশ করানো হচ্ছে। আপনি আমাদের কোডিং গ্রাউন্ড টুলে এই উদাহরণ লাইভ চেষ্টা করতে পারেন
।
import java.util.Scanner;
public class MultiplyFloatValues{
public static void main(String[] args){
float input_1, input_2, my_prod;
Scanner my_scan = new Scanner(System.in);
System.out.println("A reader object has been defined ");
System.out.println("Enter the first floating point number: ");
input_1 = my_scan.nextFloat();
System.out.println("Enter the second floating point number: ");
input_2 = my_scan.nextFloat();
my_prod = input_1 * input_2;
System.out.println("\nThe product of the two values is: " + my_prod);
}
} আউটপুট
A reader object has been defined Enter the first floating point number: 12.4 Enter the second floating point number: 15.7 The product of the two values is: 194.68
উদাহরণ 2
এখানে, পূর্ণসংখ্যা পূর্বে সংজ্ঞায়িত করা হয়েছে, এবং এর মান অ্যাক্সেস করা হয় এবং কনসোলে প্রদর্শিত হয়
public class MultiplyFloatValues{
public static void main(String[] args){
float value_1, value_2, my_prod;
value_1 = 12.4f;
value_2 = 15.7f;
System.out.printf("The two numbers are %.2f and %.2f ",value_1, value_2 );
my_prod = value_1 * value_2;
System.out.println("\nThe product of the two values are: " + my_prod);
}
} আউটপুট
The two numbers are 12.40 and 15.70 The product of the two values are: 194.68