Commit 4176483b authored by jackt's avatar jackt

save

parent 9a87b765
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="maths"/> <classpathentry kind="src" path="maths"/>
<classpathentry excluding="src/|maths/" kind="src" path=""/> <classpathentry excluding="src/|maths/" kind="src" path=""/>
......
...@@ -30,14 +30,14 @@ public class Program { ...@@ -30,14 +30,14 @@ public class Program {
String character = ""; String character = "";
int total = 0; int total = 0;
int b = binary.length() -1; int b = binary.length() -1;
int c = l-1; int c = l;
int d = resultsArray[0];
int e = resultsArray[1];
int f = resultsArray[2];
int g = resultsArray[3];
resultsArray[c] = total;
for (int a = 0; a <= b; a++) { for (int a = 0; a <= b; a++) {
if (a == 0) if (a == 0)
{ {
total = 0; total = 0;
...@@ -46,11 +46,12 @@ public class Program { ...@@ -46,11 +46,12 @@ public class Program {
char theChar = binary.charAt(a); char theChar = binary.charAt(a);
character = Character.toString(theChar); character = Character.toString(theChar);
if (a == 0 && character.equals("1")) { if (a == 0 && character.equals("1"))
{
total = total++; total = total++;
continue; }
}
else if (character.equals("0") && a == 0) if (character.equals("0") && a==0)
{ {
continue; continue;
} }
...@@ -59,54 +60,62 @@ public class Program { ...@@ -59,54 +60,62 @@ public class Program {
case 1: case 1:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 2; total = total + 2;
resultsArray[l] = total;
continue; continue;
} }
case 2: case 2:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 4; total = total + 4;
resultsArray[l] = total;
continue; continue;
} else } else
continue; continue;
case 3: case 3:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 8; total = total + 8;
resultsArray[l] = total;
continue; continue;
} else } else
continue; continue;
case 4: case 4:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 16; total = total + 16;
resultsArray[l] = total;
continue; continue;
} else } else
continue; continue;
case 5: case 5:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 32; total = total + 32;
resultsArray[l] = total;
continue; continue;
} else } else
continue; continue;
case 6: case 6:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 64; total = total + 64;
resultsArray[l] = total;
continue; continue;
} else } else
continue; continue;
case 7: case 7:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 128; total = total + 128;
resultsArray[l] = total;
continue; continue;
} else } else
break; break;
case 8: case 8:
if (character.equals("1")) { if (character.equals("1")) {
total = total + 256; total = total + 256;
resultsArray[l] = total;
continue; continue;
} }
} }
resultsArray[l-1] = total; resultsArray[l-1] = total;
} }
} }
return resultsArray; return resultsArray;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment