# Java Program to Compute Quotient and Remainder

In this java program, you'll learn how to compute Quotient and Remainder based on the input dividend and divisor provided by the user.

## How to Compute Quotient and Remainder in Java?

### Sourcecode

```
/*
Author : CodersEditor.com
Program : How to Compute Quotient and Remainder in Java?
*/
public class Main {
public static void main(String[] args) {
int dividend = 17;
int divisor = 5;
int quotient = dividend / divisor;
int remainder = dividend % divisor;
System.out.println("Quotient = " + quotient);
System.out.println("Remainder = " + remainder);
}
}
```

### Output

```
Quotient = 3
Remainder = 2
```

### Explanation

- In this java program, we have the inputs in divident and divisor variables. The values for this is 17 and 5 respectively.
- In Java, we use the divide operator (/) to find the quotient. The values in the dividend is divided by divisor.
- We used the modulus/remainder operator (%) to find the remainder.
- The end result, quotient and remainder is displayed in the console.

##### caution

- When dividing two integers, the result can be a floating point number. SInce we are assigning it to the integer variable, the result is also an int. Eg : 17/5 = 3.4 but java type casts it as we assigned the result to the integer variable.

The below code gives you the floating point value.