Find Quotient and Remainder in Java language
ADVERTISEMENTS
Find quotient and remainder in java language. In this article, you will learn how to find quotient and remainder in java language.
Source Code
// Find Quotient and Remainder in Java language
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int dn, dr, qu, rem;
// dn - denotes the dividend
// dr - denotes the divisor
// qu -denotes the Quotient
// rem - denotes the remainder
System.out.println("-----Enter the dividend & divisor to compute the quotient and remainder-----");
dn = in.nextInt();
dr = in.nextInt();
// Computes the quotient
qu = dn / dr;
// Computes the remainder
rem = dn % dr;
System.out.println("\nThe Quotient is " + qu);
System.out.println("The Remainder is " + rem);
}
}
Output
-----Enter the dividend & divisor to compute the quotient and remainder-----
45
26
The Quotient is 1
The Remainder is 19