Saturday, 3 November 2012
Koding Program Exception
public class konversi
{
public static void main (String[] args)
{
String bil = "0101001";
int[] arr_bil= new int[1000];
String[] st= new String[1000];
double hasil=0,result=0;
int a=0;
char t;
for(int i=0;i < bil.length();i++)
{
t = bil.charAt(i);
st[i]=Character.toString(t);
}
for(int i=bil.length()-1; i>=0;i--)
{
arr_bil[a]=Integer.parseInt(st[i]);
hasil= arr_bil[a]* (Math.pow(2,a));
result=result+hasil;
a++;
}
{
int resultIn = (int)result;
System.out.println("Bilangan Biner : "+bil);
System.out.println("Bilangan Desimal : "+resultIn);
}
}
}
Labels:
C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment