# Java Program to divide two binary numbers using ParseInt

**Program**

```
import java.util.Scanner;
public class DivideTwoBinaryNumbersUsingParseInt {
public void divideBinaryNumbers(String binaryNum1, String binaryNum2)
{
int num1 = Integer.parseInt(binaryNum1, 2);
int num2 = Integer.parseInt(binaryNum2, 2);
try{
int quotient = num1 / num2;
System.out.println(Integer.toBinaryString(quotient));
}
catch(ArithmeticException e)
{
System.out.println("Divide by zero exception - Zero cannot divide any number");
}
}
public static void main(String[] args)
{
DivideTwoBinaryNumbersUsingParseInt divideTwoBinaryNumbersUsingParseInt= new DivideTwoBinaryNumbersUsingParseInt();
Scanner reader = new Scanner(System.in);
System.out.print("Enter the first binary number: ");
String binaryNum1 = reader.nextLine();
System.out.print("Enter the second binary number: ");
String binaryNum2 = reader.nextLine();
System.out.print("Division of two numbers - Quotient is: ");
divideTwoBinaryNumbersUsingParseInt.divideBinaryNumbers(binaryNum1, binaryNum2);
}
}
```

**Output 1**

```
$ javac DivideTwoBinaryNumbersUsingParseInt.java
$ java DivideTwoBinaryNumbersUsingParseInt
Enter the first binary number: 10101
Enter the second binary number: 11
Division of two numbers - Quotient is: 111
```

**Output 2**

```
$ java DivideTwoBinaryNumbersUsingParseInt
Enter the first binary number: 11100
Enter the second binary number: 0
Division of two numbers - Quotient is: Divide by zero exception - Zero cannot divide any number
```