Commit 9a8a7f15 authored by samuel.boulton's avatar samuel.boulton

Sum done.

parent 12bdbd00
...@@ -71,10 +71,10 @@ public class Program { ...@@ -71,10 +71,10 @@ public class Program {
double total = 0.0; double total = 0.0;
for(int i = 0; i < input.length; i++) for(int i = 0; i < input.length; i++)
{ {
bracketsResult = (double)input[i] / 2; bracketsResult = (double)input[i] / 2.0;
System.out.println(bracketsResult + " bracket result"); System.out.println(bracketsResult + " bracket result");
powerResult = Math.pow(bracketsResult,i / 2); powerResult = Math.pow(bracketsResult,i / 2.0);
System.out.println(i + " this is i"); System.out.println(i + " this is i");
System.out.println(powerResult + " this is powerResult"); System.out.println(powerResult + " this is powerResult");
...@@ -83,7 +83,7 @@ public class Program { ...@@ -83,7 +83,7 @@ public class Program {
} }
output = total / input.length + 3; output = total / (double)(input.length + 3.0);
System.out.println(output + " output"); System.out.println(output + " output");
// TODO Auto-generated method stub // TODO Auto-generated method stub
...@@ -526,26 +526,26 @@ public static int Range (int[] input) { ...@@ -526,26 +526,26 @@ public static int Range (int[] input) {
public static double ComplexSumFunctionA (int[] input) { public static double ComplexSumFunctionA (int[] input) {
// ASK MATT // email david. // DONE AND PASSED TEST
double output = 0.0; double output = 0.0;
double bracketsResult = 0.0; double bracketsResult = 0.0;
double powerResult = 0.0; double powerResult = 0.0;
double total = 0.0; double total = 0.0;
for(int i = 0; i < input.length; i++) for(int i = 0; i < input.length; i++)
{ {
bracketsResult = input[i] / 2; bracketsResult = (double)input[i] / 2.0;
powerResult = Math.pow(bracketsResult, i / 2); powerResult = Math.pow(bracketsResult, i / 2.0);
total = total + powerResult; total = total + powerResult;
} }
output = total / input.length + 3; output = total / (double)(input.length + 3);
return output; return output;
} }
public static int[][] MatrixScalarMultiplication (int[][] matrix, int scalar){ public static int[][] MatrixScalarMultiplication (int[][] matrix, int scalar){
// DONE AND PASSED TEST
int[][] resultMatrix = new int[matrix.length][matrix[0].length]; int[][] resultMatrix = new int[matrix.length][matrix[0].length];
for(int i = 0; i < matrix.length; i ++) for(int i = 0; i < matrix.length; i ++)
......
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