Commit 76667ddc authored by samuel.boulton's avatar samuel.boulton

updated

parent 3311bd17
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
org.eclipse.jdt.core.compiler.source=1.8
......@@ -72,7 +72,7 @@ public class Program {
int[] resultsArray = new int[binaryArray.length];
/*Needs a lot of work.
char[] binCA = binaryInput[0].toCharArray();
int binTotal = 0;
int binCM = 0;
......@@ -85,12 +85,55 @@ public class Program {
}
System.out.println(binTotal);
*/
// loop to go round each string, and do something in the string to characterise it.
return resultsArray;
}
/*
public static int ConvertASingleBinaryToInt(String someBinary) {
int result = 0;
return result;
}
public static int[] ConvertWordsToInt(String[] wordArray) {
int[] resultsArray = new int[wordArray.length];
for(int i = 0; i<wordArray.length; i++) {
resultsArray[i] = ConvertASingleWordToInt(wordArray[i]);
}
return resultsArray;
}
public static int ConvertASingleWordToInt(String someWord) {
int result = 0;
if(someWord == "eleven") {result = 11;}
return result;
}
*/
......@@ -116,19 +159,42 @@ public class Program {
ArrayList<Integer> unionList = new ArrayList<Integer>();
/*this is the same as the intersection
for(int i = 0; i < intArrayA.length; i++)
{
unionList.add(intArrayA[i]);
for(int k = 0; k < intArrayB.length; k++)
{
if(intArrayA[i] == intArrayB[i])
unionList.add(intArrayB[k]);
if(intArrayA[i] != intArrayB[k])
{
unionList.add(intArrayB[k]);
unionList.add(intArrayA[i]);
}
}
}
*/
/*
for (int j = 0; j < unionList.size(); j++)
{
if(unionList.get(j) == intArrayA[i])
{
unionList.remove(j);
}
}
for(int k = 0; k < intArrayB.length; k++)
{
unionList.add(intArrayB[k]);
for(int l = 0; l < unionList.size(); l++)
{
if(unionList.get(l) == intArrayB[k])
{
unionList.remove(l);
}
}
}
*/
int[] resultsArray = new int[unionList.size()];
for(int i = 0; i<unionList.size(); i++) {
resultsArray[i] = unionList.get(i);
......@@ -143,26 +209,24 @@ public class Program {
public static int[] Intersection(int[] intArrayA, int[] intArrayB) {
// DONE AND PASSED TEST
ArrayList<Integer> intersectList = new ArrayList<Integer>();
// **************** Ask how do i return it and where does the output go???*****************
/*
//looking through intArrayA
int results = 0;
for(int j = 0; j < intArrayA.length; j++)
{
// looking through intArrayB
for(int k = 0; k < intArrayB.length; k++)
{
// Working out what is used in both arrays
if(intArrayA[j] == intArrayB[k])
{
intersectList.add(intArrayA[j]);
}
}
}
}*/
//This was here
int[] resultsArray = new int[intersectList.size()];
for(int i = 0; i<intersectList.size(); i++)
{
......@@ -352,18 +416,19 @@ public static int Range (int[] input) {
public static double StandardDeviation (int[] input) {
double output = 0;
// should be working!
float mean = 0;
float totalMean = 0 ;
// ask about calcualtions
// the mean works
for( int i = 0; i<input.length; i++)
{
mean = mean + i;
}
double output = 0;
double mean = 0;
double totalMean = 0 ;
// calculate mean
for (int i = 0; i < input.length; i++) {
mean += input[i];
}
totalMean = mean / input.length;
// calculate standard dev
for(int j = 0; j<input.length; j++)
{
output = output + j + (j - totalMean)*(j - totalMean);
......@@ -385,7 +450,7 @@ public static int Range (int[] input) {
for(int i = 0; i<input.length; i++)
{
sum = sum + 1 / input[i];
sum = (sum + 1) / input[i];
}
output = input.length / sum;
......
......@@ -109,7 +109,7 @@ class ProgramTest {
void testIntersection() {
int[] setA = {3,6,8,4,2,1};
int[] setB = {3,6,7,9,8,7,6,5,15};
int[] setB = {3,6,7,9,8,5,15};
int[] setC = {3,6,8};
......@@ -138,7 +138,7 @@ class ProgramTest {
void testDifference() {
int[] setA = {3,6,8,4,2,1};
int[] setB = {3,6,7,9,8,7,6,5,15};
int[] setB = {3,6,9,8,7,5,15};
int[] setC = {4,2,1};
......
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