Eclipse Community Forums Forum Search:

Home » Newcomers » Newcomers » Binary To Decimal(i am trying to code a binary to decimal program that could take numbers llike 11.111. this is what i have for now. if anyone could look at it for me, i would be glad)
Binary To Decimal Mon, 15 October 2012 12:23
 oti agyeiMessages: 1Registered: October 2012 Junior Member
import acm.program.*;
import java.io.*;
import acm.io.*;

public class BinaryToDecimal extends ConsoleProgram {
public void run(){
println(leftBinary()+rightBinary());
}

private int leftBinary(){
int q;
int sum=0;
int count=0;
for(int j=0;j<a;j++){
q= (int) (n *Math.pow(2,j));
count++;
sum+=q;
}
return sum;
}

private double rightBinary(){
double total=0;
double z;
int counter=0;
double b= readInt("how long is your binary number on the right: ");

for(int d=1;d<=b;d++){

for(int p=1;p<3;p++){
z=(double) (e*Math.pow(2,-p));
counter++;
total+=z;
}
}

}
private double BinToDin(){
double U;
U=leftBinary()+rightBinary();

return U ;

}
}

Goto Forum:

Current Time: Sat May 18 23:58:26 EDT 2013