Binary to Decimal Number Program in Java
import java.util.Scanner;
/**
*
* @author AFAQ
*/
public class BinaryToDecimal
{
public static void main(String[] args)
{
int binary;
Scanner sc = new Scanner(System.in);
System.out.print("Enter binary number=");
binary = sc.nextInt();
int decimal = 0;
int n = 0;
while (binary>0)
{
int temp = binary % 10;
decimal += temp * Math.pow(2, n);
binary = binary / 10;
n++;
}
System.out.println("Decimal="+decimal);
}
}
Output:
Enter binary number=101010 Decimal=42binary number binary to decimal binary to decimal conversion binary to decimal conversion method in java binary to decimal program in java c program to convert decimal to binary decimal to binary decimal to binary conversion decimal to binary conversion in java decimal to binary java decimal to binary java program how to convert binary to decimal in java how to convert binary to decimal in java program java tutorials program decimal to binary in c program to convert decimal to binary