Commit 1afe1997 authored by spray's avatar spray

OG upload

parent 7805f22d
...@@ -7,26 +7,26 @@ public class AssessmentPartOne { ...@@ -7,26 +7,26 @@ public class AssessmentPartOne {
// Debug this method so it passes the unit test. // Debug this method so it passes the unit test.
// Add comments beside any changes you make // Add comments beside any changes you make
if (num1<num2) if (num1>num2) //if num1 is bigger than num2 (changed < to >)
{ {
if (num3>num1) if (num3>num1) //and if num3 is bigger than num1
{ {
return num3; return num3; //num3 is the biggest, so return that
} }
else else
{ {
return num1; return num1; //if num1 is bigger than num3, num1 is the biggest so return that
} }
} }
else else
{ {
if (num3>num2) if (num3>num2)
{ {
return num3; return num3; //if num1 is bigger than num2, and num3 is bigger than num2, return num3
} }
else else
{ {
return num2 return num2; //else return num2 because it is larger
} }
} }
} }
...@@ -42,9 +42,23 @@ public class AssessmentPartOne { ...@@ -42,9 +42,23 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does // You should comment your code explaining what each part does
int sumOfSquares = 0; int sumOfSquares = 0; //initialise sumOfSquares
if(start < 0 || end < 0) {
return -1; //because the program can only deal with 0/positive ints, if it is 0 or lower, return -1
}
else if(start > end) {
return -1; //if the start is bigger than the end, return -1 as it can't calculate the result
}
else if(end - start <=1) {
return -1; //if the end minus the start is 1 or lower, return -1 as it can't calculate the result
}
for(int i = start + 1; i < end; i++) { //when start+1 is lower than the end
sumOfSquares += i; //sumOfSquares = itself + i
}
return sumOfSquares; return sumOfSquares;
} }
......
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