Commit a288b5ce authored by daniel.parker's avatar daniel.parker

initial

parent 7805f22d
Pipeline #226 failed with stages
...@@ -6,8 +6,10 @@ public class AssessmentPartOne { ...@@ -6,8 +6,10 @@ public class AssessmentPartOne {
// 01 - A Gentle Start // 01 - A Gentle Start
// 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) //reversed the < to > symbol to say if num1 is larger than num2.
if (num1<num2) //this is because otherwise the test will always find num3 as the largest
//since if num2 was larger than num1, it is completely ignored in the next "if" statement
//so num3 is always returned.
{ {
if (num3>num1) if (num3>num1)
{ {
...@@ -26,7 +28,7 @@ public class AssessmentPartOne { ...@@ -26,7 +28,7 @@ public class AssessmentPartOne {
} }
else else
{ {
return num2 return num2; //semicolon needed
} }
} }
} }
...@@ -43,9 +45,25 @@ public class AssessmentPartOne { ...@@ -43,9 +45,25 @@ 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;
if ((end < start) || (end == start - 1) || (start < 0) || (end < 0) || (end == start + 1)) {
// The code above is a set of conditions to test for values which are not within the set of
//parameters stated above such as values have to be positive.
sumOfSquares = -1; //sets value of sumOfSquares to -1 which shows an error.
return sumOfSquares; // returns sumOfSquares to show error so that the rest of the code is not
// run.
}
start = start + 1; // this sets the start value for the loop as one integer larger than the set start
// value, meaning that the original start value is not included in the addition.
for (int A = start; A < end; A++) //This loop increments by one each time from start to end, not
//including end as i haven't used a >= symbol.
{
sumOfSquares = sumOfSquares + A; //this adds the next number in the increment to the total
//and repeats every time the loop runs till it is completed.
}
return sumOfSquares; return sumOfSquares; //this returns the new total.
} }
} }
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