- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java Program to Compute Quotient and Remainder

In this article, we will understand how to compute the quotient and reminder in Java. Quotient and Reminder is calculated using two simple formula "Quotient = Dividend / Divisor" and "Remainder = Dividend % Divisor".

Given an integer a and a non-zero integer d, it can be shown that there exist unique integers q and r, such that a = qd + r and 0 ≤ r < |d|. The number q is called the quotient, while r is called the remainder.

Below is a demonstration of the same −

**Input**

Suppose our input is −

Dividend value: 50 Divisor: 3

**Output**

The desired output would be −

Quotient: 16 Remainder: 2

## Algorithm

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

## Example 1

Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool .

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); } }

## Output

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

## Example 2

Here, the integer has been previously defined, and its value is accessed and displayed on the console.

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); } }

## Output

The divident and the divisor are defined as 50 and 3 The quotient is 16 The remainder is 2

- Related Questions & Answers
- Java program to compute Remainder and Quotient
- C Program to Compute Quotient and Remainder?
- Program to find Quotient and Remainder in Java
- C++ Program to Find Quotient and Remainder
- C++ Program for quotient and remainder of big number
- Python Program to Read Two Numbers and Print Their Quotient and Remainder
- Golang Program to Read Two Numbers and Print their Quotient and Remainder
- Return element-wise quotient and remainder simultaneously in Python Numpy
- Divide a given scalar element with masked array elements and return arrays with Quotient and Remainder in NumPy
- Divide masked array elements by a given scalar element and return arrays with Quotient and Remainder in NumPy
- remainder() in C++ program
- C# program to accept two integers and return the remainder
- 8085 Program to compute LCM
- C program to compute geometric progression
- C program to compute linear regression

Advertisements