Calculations

Program to find Quotient and Remainder in Java

Program to find Quotient and Remainder in Java

In this tutorial, we will discuss the concept of Program to find Quotient and Remainder in Java of two numbers When the one number divided by another

In this topic, we are going to learn how to calculate quotient and remainder of two numbers using division and modular operator in Java programming language

find Quotient and Remainder

What is quotient and remainder

To find the quotient, we have used the division(/) operator. we have divided (dividend by divisor) two numbers one by another

To find remainder, we have use modular(%) operator . The dividend is divided by the divisor and the remainder is returned by the modular(%) operator

 

Java program to find quotient and remainder

Program to find quotient and remainder

Program 1

In this program, the user initialize two integer numbers using two variables as num1 and num2 and then the program calculates the quotient and remainder of the given numbers using division and modular operator

public class FindQuotientTwoNum{

public static void main(String args[]){//main method
int num1=450,num2=44;
//Variable declaration and initailization
int quotient=num1/num2;
//Calculate quotient of two numbers
int remainder=num1%num2;
//Find remainder of two numbers
System.out.println("Quotient is: "+quotient);
//Display quotient of two numbers
System.out.println("remainder is: "+remainder);
//Display remainder of two numbers

}
}

When the above code is executed, it produces the following result

Quotient is: 10
Remainder is: 10

 

Program to find quotient and remainder – entered by user

The program allows to enter two integer and then the program calculates the quotient and remainder of the given numbers  using division and modular operator

Program 2

//Java program to find quotient and remainder
import java.util.Scanner;
public class FindQuotientTwoNumUserinput{
public static void main(String args[]){//main method
Scanner scan=new Scanner(System.in);
//create a scanner instance for receives input
// from the user - input from keyboard
System.out.print("Enter the value to num1: ");
int num1=scan.nextInt();
//Reading the first number from user for num1
System.out.print("Enter the value to num2: ");
int num2=scan.nextInt();
//Reading the second number from user for num2
int quotient=num1/num2;
//Calculate quotient of two numbers
int remainder=num1%num2;
//Find remainder of two numbers
System.out.println("Quotient is: "+quotient);
//Display quotient of two numbers
System.out.println("remainder is: "+remainder);
//Display remainder of two numbers

}
}

When the above code is executed, it produces the following result

Enter the value to num1: 33
Enter the value to num1: 3
Quotient is: 10
Remainder is: 3

 

Suggested for you

Operator in Java

Data types and variable in Java

Class and main method in Java language

Method in Java language

Recursion in Java language

If statement in Java language

 

Similar post

Java code to find quotient and remainder

C code to find quotient and remainder

C++ code to find quotient and remainder

Python code to find quotient and remainder

 

C Program to Divide of two integer numbers

Java Program to Divide of two integer numbers

C++ Program to Divide of two integer numbers

Python Program to Divide of two integer numbers

 

C Program to Divide of two integer numbers using function

Java Program to Divide of two integer numbers using method

C++ Program to Divide of two integer numbers using function

Python Program to Divide of two integer numbers using function

Calculate division of two floating point numbers using pointer in C
C Program to compute Quotient and Remainder of two numbers
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

1 week ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

4 weeks ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

4 weeks ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

4 weeks ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

1 month ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

1 month ago