BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Java Program to Find Quotient and Remainder

Last Updated: August 2, 2019 by Chaitanya Singh | Filed Under: Java Examples

In this article, we will write a Java program to find Quotient and Remainder, when one number is divided by another number.

Example: Program to find Quotient and Remainder

In the following program we have two integer numbers num1 and num2 and we are finding the quotient and remainder when num1 is divided by num2, so we can say that num1 is the dividend here and num2 is the divisor.

public class JavaExample {
    public static void main(String[] args) {
        int num1 = 15, num2 = 2;
        int quotient = num1 / num2;
        int remainder = num1 % num2;
        System.out.println("Quotient is: " + quotient);
        System.out.println("Remainder is: " + remainder);
    }
}

Output:
Java Program to Find Quotient and Remainder

To compute the quotient and remainder we have created two variables with the name quotient and remainder respectively.

To find the quotient we divide the num1 by num2 using / operator. Since both the variables num1 & num2 are integers, the result will be integer despite the fact that the result of 15/2 is 7.5 mathematically. So the value assigned to the variable quotient after the operation is 7.

To find the remainder, we use the % operator. The remainder of 15/2 i.e 1 is assigned to the variable remainder after operation.

At the end of the program the values of variables quotient and remainder are printed.

Related Java Examples

1. Java Program to calculate simple interest
2. Java program for selection sorting
3. Java program to print alternate prime numbers
4. Java program to count the occurrence of a character in a string
5. Java program to break integer into digits

Top Related Articles:

  1. Java Program to Calculate average using Array
  2. Java Program to Add two Binary Numbers
  3. Java Program to find largest of three numbers using Ternary Operator
  4. Java Program to Find Factorial using For and While loop
  5. Java Program to Perform Arithmetic operation using Method Overloading

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Java Examples

  • Check Odd-even
  • Linear Search
  • Binary Search
  • Floyd's Triangle
  • Reverse number
  • Random Number
  • first n prime numbers
  • Disp prime Numbers
  • Check Prime number
  • Palindrome String
  • Find factorial
  • Sum of elements of Array
  • Area of rectangle
  • Area of Square
  • Area of Triangle
  • Circle

Tutorials

  • Java Tutorial
  • OOPs Concepts
  • Java String
  • Exception handling
  • Java Multithreading
  • Java I/O
  • Java Serialization
  • Java Regex
  • Java AWT
  • Java Swing
  • Java Enum
  • Java Annotations

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap