Program to find Quotient and Remainder in Java

JavaObject Oriented ProgrammingProgramming

To find quotient and remainder in Java, the code is as follows −


 Live Demo

public class Demo{
   public static void main(String[] args){
      int my_dividend = 11, my_divisor = 7;
      int my_quotient = my_dividend / my_divisor;
      int my_remainder = my_dividend % my_divisor;
      System.out.println("The value of computed quotient is = " + my_quotient);
      System.out.println("The value of computed remainder is = " + my_remainder);


The value of computed quotient is = 1
The value of computed remainder is = 4

A class named Demo contains the main function, where the dividend and divisor values are defined. The quotient and the remainder are found by using the ‘/’ operator and the ‘%’ modulus operator respectively. The values are assigned to different variables and the results are displayed on the console.

Published on 07-Jul-2020 13:19:03