**Question 74 : Write a program in Java to convert a binary number into decimal notation.**

**Java Program :**

class bintodec

{

static void main(String m)

{

String n="";

int i=0,d=m.length()-1;

double a=0;

for(d=m.length()-1;d>=0;d--)

{

a=a+(Integer.parseInt(n+m.charAt(d))*Math.pow(2,i));

i++;

}

System.out.print("The decimal value of "+m+" is : "+a);

}

}

## No comments:

## Post a Comment