i need help i dont know what to do, heres the psudocode and java code
Function (BinaryNumber is String) returns Integer
Var DecimalNumber is Integer initialized as 0
Var Power is Integer initialized as 0
Var BinaryDigit is Integer
For (I (start value is length of BinaryNumber) to (end value is 1))
BinaryDigit = StringToInteger (BinaryNumber (I))
- BinaryNumber (I) represents the Ith character in the string – this is similar to the substring function
DecimalNumber = DecimalNumber + (BinaryDigit * 2 ** Power)
- ** is the “power of” operator
Power = Power + 1
End for
Return DecimalNumber
End Function
The "BinaryToDecimalGood" class.
import java.awt.*;
import hsa.Console;
public class BinaryToDecimalGood
{
static Console c; // The output console
public static void main (String[] args)
{
c = new Console ();
String BinaryNumber;//return as intiger
int DecimalNumber = 0;
int BinaryDigit;
int Power = 0;
c.println("What is the binary number you wish to convert:");
c.println();
for (int i = binary2.length;i <=1;i ++)
{
BinaryDigit = StringToInteger (BinaryNumber (i));
DecimalNumber = DecimalNumber + (BinaryDigit * 2 ** Power);//** is the "power of" operator
Power != Power + 1;
}//end loop
Return DecimalNumber;
} // main method
} // BinaryToDecimalGood class
if any1 can help it will be greatly appreated , please keep in mind im in gr 11 and if possible could you keep it a simple as possible thanks