কম্পিউটার

ভাগফল এবং অবশিষ্টাংশ গণনা করার জন্য জাভা প্রোগ্রাম


এই নিবন্ধে, আমরা বুঝতে পারব কিভাবে জাভাতে ভাগফল এবং অনুস্মারক গণনা করা যায়। ভাগফল এবং অনুস্মারক দুটি সহজ সূত্র "ভাগ =লভ্যাংশ / ভাজক" এবং "অবশিষ্ট =লভ্যাংশ % ভাজক" ব্যবহার করে গণনা করা হয়।

একটি পূর্ণসংখ্যা 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

  1. কিউবয়েডের সারফেস এরিয়া এবং ভলিউম খুঁজে পেতে জাভা প্রোগ্রাম

  2. জাভা 8 এবং জাভা 9 এর মধ্যে পার্থক্য?

  3. জাভা প্রোগ্রামে সুপার() এবং এই() এর মধ্যে পার্থক্য

  4. পাইথন প্রোগ্রাম দুটি সংখ্যা পড়তে এবং তাদের ভাগফল এবং অবশিষ্টাংশ মুদ্রণ করে