# 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

**Recent Posts**

- UP Board Math Class 7th Chapter 6 - रेखीय समीकरण April 13, 2022
- UP Board Math Class 7th Chapter 3 - साँख्यिकी April 13, 2022
- UP Board Math Class 7th Chapter 2 - घातांक April 13, 2022
- Bubble Sort in String Program in Java April 4, 2022
- Palindrome String April 4, 2022
- Piglatin Form Program in Java April 4, 2022
- Find Vowels And Capital Letter in Array Program in Java April 4, 2022
- Find Positive and Negative Numbers in Array Program in Java April 4, 2022
- UP Board Math Class 7th Chapter 1 - परिमेय संख्याएँ March 24, 2022
- Peterson Number Program in Java March 21, 2022
- Mystery Number Program in Java March 21, 2022
- Print Capital String Program in Java December 31, 2021
- Fascinating Number Program in Java November 14, 2021
- Evil Number Program in Java November 14, 2021
- Insertion Sort Program in Java November 7, 2021
- Deleting Element From Array Program in Java November 7, 2021
- Adding Element In Array Program in Java November 7, 2021
- Capricorn or Kaprekar Number Program in Java October 16, 2021
- LCM and HCF of two numbers Program in C October 6, 2021
- Find day of week from a given date Program in C October 6, 2021