এই নিবন্ধে, আমরা বুঝতে পারব কিভাবে জাভাতে ভাগফল এবং অনুস্মারক গণনা করা যায়। ভাগফল এবং অনুস্মারক দুটি সহজ সূত্র "ভাগ =লভ্যাংশ / ভাজক" এবং "অবশিষ্ট =লভ্যাংশ % ভাজক" ব্যবহার করে গণনা করা হয়।
একটি পূর্ণসংখ্যা a এবং একটি অ-শূন্য পূর্ণসংখ্যা d দেওয়া হলে, এটি দেখানো যেতে পারে যে সেখানে অনন্য পূর্ণসংখ্যা q এবং r রয়েছে, যেমন a =qd + r এবং 0 ≤ r <|d|। সংখ্যা q কে ভাগফল বলা হয়, আর r কে বলা হয় অবশিষ্টাংশ।
নীচে একই -
এর একটি প্রদর্শন রয়েছে৷

ইনপুট
ধরুন আমাদের ইনপুট হল −
Dividend value: 50 Divisor: 3
আউটপুট
কাঙ্খিত আউটপুট হবে −
Quotient: 16 Remainder: 2
অ্যালগরিদম
Step1- Start Step 2- Declare four integers as my_dividend , my_divisor, my_quotient, my_remainder Step 3- Prompt the user to enter two integer value that is my_dividend , my_divisor or define the integers Step 4- Read the values Step 5- Use the formula to find the quotient and the reminder "Quotient = Dividend / Divisor" and "Remainder = Dividend % Divisor" Step 6- Display the result Step 7- Stop
উদাহরণ 1
এখানে, একটি প্রম্পটের উপর ভিত্তি করে ব্যবহারকারী দ্বারা ইনপুট প্রবেশ করানো হচ্ছে। আপনি আমাদের কোডিং গ্রাউন্ড টুলে এই উদাহরণ লাইভ চেষ্টা করতে পারেন
।
import java.util.Scanner;
public class RemainderQuotient {
public static void main(String[] args) {
int my_dividend , my_divisor, my_quotient, my_remainder;
System.out.println("Required packages have been imported");
Scanner my_scanner = new Scanner(System.in);
System.out.println("A scanner object has been defined ");
System.out.print("Enter the value of dividend : ");
my_dividend = my_scanner.nextInt();
System.out.print("Enter the value of divisor : ");
my_divisor = my_scanner.nextInt();
my_quotient = my_dividend / my_divisor;
my_remainder = my_dividend % my_divisor;
System.out.println("The quotient is " + my_quotient);
System.out.println("The remainder is " + my_remainder);
}
} আউটপুট
Required packages have been imported A reader object has been defined Enter the value of dividend : 50 Enter the value of divisor : 3 The quotient is 16 The remainder is 2
উদাহরণ 2
এখানে, পূর্ণসংখ্যা পূর্বে সংজ্ঞায়িত করা হয়েছে, এবং এর মান অ্যাক্সেস করা হয়েছে এবং কনসোলে প্রদর্শিত হয়েছে।
public class RemainderQuotient {
public static void main(String[] args) {
int my_dividend , my_divisor, my_quotient, my_remainder;
my_dividend = 50;
my_divisor = 3;
System.out.println("The divident and the divisor are defined as " +my_dividend +" and " +my_divisor);
my_quotient = my_dividend / my_divisor;
my_remainder = my_dividend % my_divisor;
System.out.println("The quotient is " + my_quotient);
System.out.println("The remainder is " + my_remainder);
}
} আউটপুট
The divident and the divisor are defined as 50 and 3 The quotient is 16 The remainder is 2