Java program to compute Remainder and Quotient

Java Programming Java8Object Oriented Programming

Read the divisor and dividend from the user using the nextInt() method of the scanner class. The operators % and / in Java are used to compute Remainder and Quotient.

Example

public class ComputeQuotientandRemainder {
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the value of the divisor:: ");
      int divisor = sc.nextInt();
      int divident = sc.nextInt();

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

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

Output

Enter the value of the divisor::
125
5
Quotient value:0
Remainder value:5
raja
Published on 26-Apr-2018 08:48:48
Advertisements