```
//package
import java.util.*;
// the main class BinaryToDecimalCalculator
public class BinaryToDecimalCalculator
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);//scanner object for input
//declaration of input variables
int binary, exponent=0;
float decimal, total=0 , currentNumber ;
boolean error =false;//check for input errors
//the user inputs a binary integer
System.out.print("Enter binary number: ");
binary = input.nextInt();
//processing formular
do
{
//fetches binary digits
decimal = (float)(binary)/((float)10);
binary = binary / 10;
currentNumber = (int)(10 * (decimal - binary));
//prompts the user input when it is not a binary integer
/*if(currentNumber >1 || )
{
System.out.println("The number you typed is not a binary value, re-run the program");
error = true;
break;
}
else
{
//computes the decimal value
total += (currentNumber * (Math.pow(2, exponent)));
exponent++;
}
}while(decimal !=0);//checks whether extraction is finished
if(!error)
System.out.println("The decimal equivalent of binary integer is : "+(int)total);
}
}
```

0

*Edited
by Ezzaral*: Added code tags. Please use them to format any code that you post.