Java program to compute quotient and remainder

Write a java program to compute quotient and remainder

In this program, the quotient and remainder find in java programming language.

The different parts of division are dividend, divisor, quotient and remainder. Quotient can be defined as the resultant of the division. Formula for quotient is Quotient = Dividend/Divisor. In division, a number is divided by another number to get the output in the form of another number. The dividend is the number that is getting divided, and the divisor is the number that divides the given number. In fraction, the numerator is dividend, denominator is divisor, and when numerator is divided by the denominator, the result will be quotient. For, instance, suppose we have to divide 20(dividend) by 4(divisor); we will get 5, which is the quotient.

Remainder is defined as a value that is left after division. As an instance, if we divide 25 with 4, we will get 1 as a remainder. If the number divides another number completely, the remainder will be 0.
Remainder is always smaller than the divisor, if it is large, that means the division is not completed. But remainder can be less or greater than the quotient; for instance, if we divide 41 by 7, we will get 5 as a quotient, and 6 as a remainder which is less than divisor greater than the quotient. we know the method of Division = Divisor x Quotient + Remainder. so, the formula for remainder will be Remainder = Dividend - (Divisor x Quotient)

Here, we have created two variables dividend and divisor. we are calculating the quotient and remainder by dividing 55 by 6.
To find the quotient, we have used the / operator, we have divided dividend (55) by divisor (4). Since both dividend and divisor are integers, the result will also be integer.
55 / 6 // result 8(integer)
Likewise, to find the remainder we use the % operator. Here, the dividend is divided by the divisor and the remainder is returned by the % oprtator.
55 % 6 // result 1
finally, quotient and remainder are printed on the screen using println() function.

  • Program:

public class QuotientRemainder {

  public static void main(String[] args) {

    int dividend = 55, divisor = 6;

    int quotient = dividend / divisor;
    int remainder = dividend % divisor;

    System.out.println("Quotient = " + quotient);
    System.out.println("Remainder = " + remainder);
  }
}

  • Output:

Quotient = 9
Remainder = 1

  • Visit:

Java program to print an Integer Here
Java program to add two integers Here
Java program to find ASCII value of a character Here

0 comments