Java Program to Calculate Quotient and Remainder

In this example, we are giving a program to calculate quotient and remainder.


To calculate quotient and remainder:

  1. # To calculate quotient and remainder
  2. public class QuotientRemainder {
  3. public static void main(String[] args) {
  4. int dividend = 25,int divisor = 4;
  5. int quotient = dividend / divisor;
  6. int remainder = dividend % divisor;
  7. System.out.println("Quotient = " + quotient);
  8. System.out.println("Remainder = " + remainder);
  9. }
  10. }

Output:

Quotient = 6
Remainder = 1